Request object in Application_Start event

后端 未结 2 828
情深已故
情深已故 2021-01-05 08:13

We currently use this line of code to get the current applications url in the Application_Start event.

string sApplicationURL = HttpContext.Current.Request.U         


        
相关标签:
2条回答
  • 2021-01-05 08:44

    Microsoft has a all-in-one article on all breaking changes including this one,

    http://learn.iis.net/page.aspx/381/aspnet-20-breaking-changes-on-iis-70/

    Yes, its content somehow comes from http://mvolo.com (and the reason is simple).

    0 讨论(0)
  • 2021-01-05 08:58

    Have a look at this: http://mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx

    In summary, the error occurs because the Request context is not longer available to the Application_Start event. This blog states two choices to deal with this error:

    1) Change your code to work w/o Request, or 2) Modify your application to run in Classic Mode (not recommended).

    To get the ApplicationPath, use HttpRuntime.AppDomainAppVirtualPath.

    0 讨论(0)
提交回复
热议问题