0

When I try to debug my Web Application Project, the Chrome browser starts and then redirects to http://www.localhost/default.aspx, resulting in a 404 error.

Why is the www prepended to the hostname? I looked in the web.config for rewrite rules, the master page for rewrite logic and also the Global.asax.vb file where I just have this:

Protected Sub Application_Start()
    AreaRegistration.RegisterAllAreas()
    GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters)
    RouteConfig.RegisterRoutes(RouteTable.Routes)
    BundleConfig.RegisterBundles(BundleTable.Bundles)
End Sub

But nowhere do I find why the www is prepended. Where else could it be defined?

UPDATE 1

When I look ath the default.aspx file properties, I see this:

Browse to URL = ~/Default.aspx

When I build it, it redirects to http://www.localhost/Default.aspx

When I go to Project->Properties->Web->Servers I see this as the project URL: http://localhost:64710/

When I create a new project and build that, it redirects to http://localhost:64697/ and show a page successfully.

So there must be a configuration somewhere in my project that I'm overlooking. I DON'T want to create a new project and copy over all the old stuff.

What can I do?

Adam
  • 6,041
  • 36
  • 120
  • 208
  • If you create a new default web project, how about the result? If you view the property of the default.aspx or view the whole project Properties->Web->Servers, whether you change one of them in your side? I suggest you visit your property properties and check the Project Url. – Jack Zhai Aug 30 '17 at 02:00
  • Hey! Thanks! I added update 1 based on your suggestions. I still have the same issue. Can you help? – Adam Aug 30 '17 at 11:15

2 Answers2

0

I also test it in my side, I couldn't get the same issue as yours even if I also think about the local IIS or other servers, but it seems that you didn't really deploy your web project to IIS(we could edit the URL there).

Since a simple app doesn't have this issue, and you just get this issue in debugging, I think we would think about the code in your project. The Application_start or the default.aspx file or others where you redirect the default URL.

A simple workaround for you is that you could use the Find feature in VS IDE, and try to find the "www" in your whole solution directly.

Or you could really share a simple sample here using one drive, we try to find it in our side for you.

enter image description here

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20
  • @Flo,Just ignore "deploy to IIS", I mean that publish to the IIS, if you just debug web code locally, just ignore it. For the previous issue, (1) Just find "www" using the Find tool.(2) Using Fiddler to capture the request's before launch the app.(3) Visit the URL directly: http://localhost/default.aspx after you run your app? What is the result? – Jack Zhai Aug 31 '17 at 10:17
0

Ok. I solved it:

  1. Goto Project -> properties -> Web
  2. Under Servers, set dropdown to Local IIS
  3. Set the project URL to the URL you've setup in your local IIS, e.g. http://www.example.com/
  4. Upon running, I then got the error unable to access the iis metabase (see this post on how to fix that), basically run Visual Studio as Administrator.

And done!

Adam
  • 6,041
  • 36
  • 120
  • 208