asp.net - How do I get the host domain name in ASP .NET without using HttpContext.Current.Request? -


An ASP on IIS7. Net application is running. I am using the current URL which is running the site to set some stable properties of a class in my application. To do this, I am using this domain name (insde to the static manufacturer of the class):

  var host = HttpContext.Current.Request.Url.Host;  

And it works fine on my Dev Machine (Windows XP / Cassini). However, when I deploy IIS 7, I get an exception: "The request is not available in this context"

I'm guessing this because I created this code in a stable creator of an object I am using, which is being executed in IIS before any request; And unless there is a request, Cassini does not trigger the stable manufacturer. Now, I was not basically like the idea of ​​dragging the domain name from the request for this reason, but this was the only place I got) =>

So, is there anyone else Know I can get the host domain name? I'm assuming that ASP The net should be aware of this at HTTU Extensions at an independent level, I do not know how to access it.

This is because the domain is in the request ... that's what is being asked for. For example, these are some stack exchange sites:

If you ping them You will point out all those same IP / web server and will be served by the same app (or many apps in this case, but the example assumes that this was a big part) ... but the application does not know which One can come up with a request to request the server for that site. Each request can be for a different domain ... then the app does not know it.

If this does not change, you can store it as an app in Setting up web.config .


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -