i can't add #region to .ashx in visual studio 2010

纵然是瞬间 提交于 2020-01-24 12:54:07

问题


i create a generic handler (ashx) but i am trying to add region in my code like the following

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

there is no error but the problem that there is no expand and collapse.

please any advice ? note: i am using visual studio 2010


回答1:


hi i think i figure out the answer my self

in visual studio go to:

1- Tools -> option -> select Text Editor.
2- in the right pane add an extension "ashx" and choose from the drop down list which editor u use .. i select microsoft visual c#.
3- in the bottom check on "map extensionless to : the same selection above.
4- click ok and close the ashx page and reopen it.

thx every body for the answers




回答2:


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




回答3:


EDIT: Hang on a minute - I've just re-read your question. An .ashx file, like an .asmx or .aspx file is a markup file, not a code file. You can't use regions in these files. You can use regions in the code behind files associated with them (e.g. the .ashx.cs files) only.

Original Answer: Generally, whenever I get these sort of unexplained odd behaviours in VS2010, I reset all the settings, which normally resolves the issue.

Try Tools->Import and Export Settings->Reset All Settings and see if that fixes your region issue.

If not, it may be related to a bad add-in or extension. Try disabling extensions/add-ins to see if that fixes your problem, alternatively try starting up in safe mode and see if the IDE behaves:

DEVENV.EXE /safemode

Hope this helps.




回答4:


#region yourRegionName
//your code
#endregion


来源:https://stackoverflow.com/questions/5310631/i-cant-add-region-to-ashx-in-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!