I cannot add #region to .ashx in visual studio 2010

I am creating a generic handler (ashx), but I am trying to add a scope to my code, as shown below.

#region MyRegionName context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); #endregion 

there is no error, but the problem is that there is no expansion and failure.

please advice! note: i am using visual studio 2010

+2
source share
4 answers

Hi, I think I will find out the answer myself.

in the visual studio follow the link:

1- Tools → option → select Text Editor.
2- in the right pane add the extension "ashx" and select from the drop-down list that the u editor uses. I choose microsoft visual c #.
3- in the lower check on the map without restrictions: the same choice is higher.
4- click ok and close the ashx page and open it again.

thank you every body for answers

+7
source

This is by design, see explanation here: http://forums.asp.net/t/1162769.aspx#1928580 . The problem is that the ashx file is not processed by the C # editor, but by the ASP.NET editor.

+2
source

EDIT: Wait a minute. I just re-read your question. An .ashx file, such as a .asmx or .aspx file, is a markup file, not a code file. You cannot use regions in these files. You can only use regions in the code behind the files associated with them (for example, .ashx.cs files).

Original answer: As a rule, whenever I get such inexplicable odd behavior in VS2010, I reset all settings that usually fix the problem.

Try tools-> Import and Export Settings → Reset All Settings and check if this fixes the problem in your area.

If not, this could be due to a bad add-in or extension. Try disabling extensions / add-ins to make sure this fixes your problem, try starting in safe mode and see if the IDE leads:

 DEVENV.EXE /safemode 

Hope this helps.

+1
source
 #region yourRegionName //your code #endregion 
-3
source

Source: https://habr.com/ru/post/1389059/


All Articles