开发者

IIS ASP.NET MVC3 doesn't show my website

开发者 https://www.devze.com 2023-03-08 00:32 出处:网络
So I\'ve set up IIS 7.5 to host my ASP.NET MVC website on my own local machine, but when I surf to http://localhost/ I just get this:

So I've set up IIS 7.5 to host my ASP.NET MVC website on my own local machine, but when I surf to http://localhost/ I just get this:

Welcome to ASP.NET MVC!

To learn more about ASP.NET MVC vi开发者_StackOverflow中文版sit http://asp.net/mvc.

A very basic HTML page with only this on it. No CSS or anything.

I haven't used IIS before, so I don't know what settings I need to change in order for this to work, but this is what I've done:

Added a new Site "MySite"

Set the Physical path to the root folder of my asp.net project

Tested the settings (everything OK)

Edited the "MySite" Application Pool and set it to .NET framework version v4.0.30319

What else do I need to do to make my website display? Thanks.

EDIT: please read this

I'll give a step-by-step walkthrough of what exactly I do:

1) I create a new ASP.NET MVC3 Razor web project. I don't do anyting but save and build the project.

2) I open IIS Manager

3) I go to Sites -> Add Web Site

4) I fill in following data:

Site Name: MyWebSite

Application Pool: MyWebSite

Physical Path: Visual Studio 2010\Projects\MyOwnProject\MyOwnProject (Project root folder)

Connect as: My PC's login and password. Test Settings is succesful

I leave the rest of the settings as it is and press OK

5) I go the Application Pools and edit the basic settings of MyWebSite to change the .NET framework to the latest version (v4.0.30319)

6) I select MyWebSite and click Browse *:80 (http) to go the web site. It opens up Chrome and I see the following page:

<h2>Welcome to ASP.NET MVC!</h2>

<p>

    To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.

</p>

That's it. Nothing more. What am I missing here?


That looks like it is working (at least that's an MVC page it is displaying.) Maybe you need to alter your default route in Global.asax.cs to hit a different controller?


Do you have a Layout.cshtml in your shared folder and is your ViewStart pointing to it?

Edit: I do remember having an issue like this at one point. I think it has to do with static resources pointing to the root which by default will be pointing to another App in IIS. I'm not sure if this is exactly the issue but what I do is setup an address in my host file for each application. For me the host file is :

C:\Windows\System32\drivers\etc\hosts

You have to run notepad or something as Administrator to edit it and add the following line:

127.0.0.1 MySite

This will allow you to simply navigate to http://mysite without any conflicts. Just double check your IIS setting so that the hostfile address point to the right physical path.


It seems I've fixed it, I don't know how or why this works. But this is what I've done:

In Visual Studio, I went to the Properties of my project. There, in the Web tab, I selected "Use local IIS Web Server", filled in "http://localhost/MyWebSite" and hit "Create Virtual Folder".

Save and build the project and suddenly it worked. However, I am not able to debug my project from Visual Studio now. But when I change the Web configuration back to "Use Visual Studio Development Server" it still works and I can debug again...

Doesn't make too much sense because you should be able to debug from IIS right?

0

精彩评论

暂无评论...
验证码 换一张
取 消