开发者

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

开发者 https://www.devze.com 2023-02-17 09:29 出处:网络
i create a generic handler (ashx) but i am trying to add region in my code like the following #region MyRegionName

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


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


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.


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.


#region yourRegionName
//your code
#endregion
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号