asp.net - How do I get the IP address of the current website in global.asax? -


i'd in application_start method, can write 'robots.txt' file if site running on test server.

thanks

i thought old school, using servervariables collection, following worked nicely in test app, running under built in vs web server:

void application_start(object sender, eventargs e) {   // code runs on application startup   string localaddress = context.request.servervariables["local_addr"];   // returns "::1" when running under vs server, throws    // exception under iis express, assume under iis. } 

the next best option can come like:

void application_start(object sender, eventargs e) {   // code runs on application startup   string servername = server.machinename; } 

which works on both vs , iis express, if know name of test or live servers, check against instead?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -