ASP.NET Developer Notes

Ryan Garaygay's ASP.NET notes online

ASP.NET Development Server cannot be accessed using non-localhost URL

An interesting point about the ASP.NET Development Server (previously named "Cassini") was raised hours ago by Alvin, a coworker of mine.

Forgive my ignorance but it seems that the said builtin server was constrained to be accessed only with localhost or 127.0.0.1 and would not work when using your IP (non loopback) nor machine name.

For IE you get : Internet Explorer cannot display the webpage

For Firefox : Unable to connect. Firefox can't establish a connection to the server at 192.168.1.xxx:PPPP (port number). The page title appears as Problem loading page 

Not much there but if you use Fiddler you would see that it is returning an HTTP Error 500 which refers to "Bad Gateway".

Somehow that tells me, it's not your code but something with the server or the machine.

Looking around, here's what I found:

Troubleshooting the ASP.NET Development Server

"Page Cannot Be Displayed" Error (502 Error)"

One possible cause of a 502 error or an error indicating that the page cannot be displayed is that the browser cannot resolve a URL containing "localhost" and a port number, such as http://localhost:8080/ExampleWebSite/Default.aspx. The ASP.NET Development Server works exclusively with localhost, and by default, uses a randomly selected port number for each request.

Furthermore, from Web Servers in Visual Web Developer link you will find:

If you cannot or do not want to use IIS as your Web server, you can still test your ASP.NET pages by using the ASP.NET Development Server. The ASP.NET Development Server, which is included with Visual Web Developer, is a Web server that runs locally on Windows operating systems, including Windows XP Home Edition. It is specifically built to serve, or run, ASP.NET Web pages under the local host scenario (browsing from the same computer as the Web server). In other words, the ASP.NET Development Server will serve pages to browser requests on the local computer. It will not serve pages to another computer. Additionally, it will not serve files that are outside of the application scope. The ASP.NET Development Server provides an efficient way to test pages locally before you publish the pages to a production server running IIS.

Although it may seem that accessing the site from the same machine but using your IP would seem like accessing it locally, it doesn't seem to be the case. Could be that technically it would go out of your local machine first then, find which machine the IP points to so effectively it's being accessed externally already (sorry can't explain better than that). What's interesting though is that accessing the machine results in the same behavior for some reason. Maybe someone can clear it up for us. Or maybe Cassini is really accessible this way and I'm just missing something.

One last thing, for those who wish to specify a specific port to use with ASP.NET Development Server here's a link : How to: Specify a Port for the ASP.NET Development Server

Might seem pretty obvious for some but for those of us who haven't cared about this before then hopefully something to add to our knowledge base (or if I'm missing something, at least something to spark your curiosity)

Comments

Muhammad Safdar said:

I'm using VS2005 & SQL Express in Windows Vista with IIS7 and was facing the same problem from previous 3 days, but after monitoring the processes I came to know that this problem is caused by my antivirus (NOD32 3.0), after uninstall it works fine.

Best Regards,

Safdar.

# August 10, 2008 7:38 AM

Pazdziernik said:

Scenario: I need IT to open up IIS 5.0 on my Windows XP SP2 Pro box. I can't do this because the IIS install wants prompts me to insert Windows CDs. So I need to demo ASP.NET app. I can run WebDev locally. Remote access is a problem. I can not even run WebDev with my IP address hard-coded. I searched for information and found your post. Thanks. Next, I'm going to look into Mono with Apache HTTP Server.

# October 22, 2008 11:40 AM

Sajeev Nair said:

replacing localhost with 127.0.0.1 worked for me

but I had to do it manually ie. first the debug results in the page not displayed, then I manually type 127.0.0.1

I also use NOD32(x64) 3.0.6

# December 18, 2008 11:36 AM

Nishant Dhawan said:

Hi all,

Thank you so much guys....I was also using NOD 32 3.0 and it was not working for me n then I replaced localhost with 127.0.0.1 and then it worked...Thanks again for ur comments.

# January 9, 2009 10:51 PM

Arman said:

Salam everyone

If you are using node32 as anti virus you have to set 127.0.0.1 as trusted zone in its personal firewall settings.

# March 3, 2009 8:12 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)