Inside the Application_Start of my Global.asax.cs, I am trying to get the current application path using:
var virtualPath = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpRuntime.AppDomainAppVirtualPath;
This will return, for example: http://localhost:99/MySite/
Then I will use this URL and do the following:
var pageToHit = virtualPath + Pages\MyOtherPage.aspx var client = new WebClient(); client.DownloadData(dummyPageUrl);
All this is fine when I run a project in IIS 6 or the Visual Studio Embedded Web Server, but in IIS 7 itβs all crazy as I get the request "System.Web.HttpException: Request" in this context ".
I know this topic: Request in this context is not available
However, I was wondering if anyone had any ideas on how to do this without changing the project to run in classic mode.
MaYaN source share