Windows Azure Platform Developer Center >
Microsoft Visual Studio 2010 Beta 2 Forums
>
Windows Azure
>
Automatically run locally as http://localhost, not http://127.0.0.1?
Automatically run locally as http://localhost, not http://127.0.0.1?
- I'm playing with LiveID, and it would make things a little simpler if VS launched my app as http://localhost instead of http://127.0.0.1. Is this possible?
It's a little easier this way because LiveID insists on hostnames, including localhost, and won't work with IP numbers. Typing http://localhost each time is getting to be a nuisance.
Answers
- Hi mh415How about in Global.ASAX Application_BeginRequest doing something like:
#if DEBUG
if (Request.Uri.ToString().StartsWith("http://127.0.0.1"))Response.Redirect(string.format("http://localhost:{0}", Request.Uri.Port));#endif
I haven't tested this or anything, just thought I'd share an idea. Hopefully you can see what I'm driving at with the approach.TaBWC;- Marked As Answer bymh415 Monday, November 09, 2009 10:08 PM
All Replies
- Hello, do you mean Development Fabric? Yes, you can use localhost instead of 127.0.0.1. For example, if you're using the default port number 81, and you navigate to http://localhost:81/, it will work fine.
If you mean you hope the address is automatically set to localhost when launching the debug session in Visual Studio, this is currently not supported.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights. Hello, do you mean Development Fabric? Yes, you can use localhost instead of 127.0.0.1. For example, if you're using the default port number 81, and you navigate to http://localhost:81/, it will work fine.
If you mean you hope the address is automatically set to localhost when launching the debug session in Visual Studio, this is currently not supported.
Yes, I'm talking about the Dev Fabric. Yes, I do currently type in http://localhost each time, however it's getting tedious.
I guess launching as http://localhost isn't supported. I'll come up with a workaround.- Hi mh415How about in Global.ASAX Application_BeginRequest doing something like:
#if DEBUG
if (Request.Uri.ToString().StartsWith("http://127.0.0.1"))Response.Redirect(string.format("http://localhost:{0}", Request.Uri.Port));#endif
I haven't tested this or anything, just thought I'd share an idea. Hopefully you can see what I'm driving at with the approach.TaBWC;- Marked As Answer bymh415 Monday, November 09, 2009 10:08 PM
- You could also use the computer name, check out my tip here:
An easier way to access the Windows Azure local development fabric from another computer
http://blog.ehuna.org/2009/10/an_easier_way_to_access_the_wi.html
I specifically use this trick to access the local development fabric from another computer, but you could do it from the same machine as well. You could then use the NetBios name or even a full DNS name, like mycomputer.mycompany.com.- Proposed As Answer byEmmanuel Huna Monday, November 09, 2009 8:30 PM
- Thanks, that did the trick. MVC.NET doesn't contain Application_BeginRequest() in Global.asax by default, and since I don't know ASP.NET webforms I was unaware of its existence. Simply adding it to Global.asax with a modification for MVC.NET worked:
protected void Application_BeginRequest(Object sender, EventArgs e) { if (Request.Headers["Host"] == "127.0.0.1") { Response.Redirect(string.Format("http://localhost")); } }
Thanks again.


