Using IIS Server instead of IIS Express in Visual

2020-08-17 06:46发布

How can we configure our already developed ASP.Net website to use IIS Server instead of using IIS Express in VS2015?

IIS Express is the default server in Visual Studio 2015. My website runs fine with ASP.NET web Development server in Visual studio 2012 but when i run it in VS2015 , it does not loads the css and images .

So, i want to run it with IIS Server and not IIS Express in VS2015. Can anyone help me out ?

3条回答
贼婆χ
2楼-- · 2020-08-17 06:48

The problem with loading the CSS and Images is likely because of the paths you have used, not with the web host.

"/Images/Image1.jpeg" always looks for an Image subfolder with an Image1.jpg in the same place as the current page.

"~/Images/Image1.jpeg" will look for an Images folder with an Image1.jpg starting from the site root. Using the tilde (~) is going to address other things as well (user controls, pages in folders, etc.

The same holds true for stylesheet hrefs. If you want to diagnose this kind of "resource failing to load" problem, you can use the developer tools (IE, Chrome, FireFox/FireBug, Safari all have them) and start a capture on the network tab. That will list a request to each resource (image, css, js, etc) and what the request path and HTTP status (404 - not found, 200 - OK, etc) is.

EDIT: Aside from the above which is directed to help you find the source problem of not loading CSS and Images, you will have to do a few things.

  • Create an application in your local IIS's Default Web Site that points to your project's root.
  • Make sure the Build and Start Options tabs are set correctly in the website project properties. Be sure to set the "Use custom web server" value with the URL you created in local IIS.

At that point you should be able to Start Debugging, but you should really consider conversion to a Web Application if you want a less fragile program and an easier development experience.

Key differences between WS/WAP - https://msdn.microsoft.com/en-us/library/dd547590(v=vs.110).aspx

Converting from WS to WAP - https://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx

查看更多
戒情不戒烟
3楼-- · 2020-08-17 06:52

Right click on your project and go to Properties and then Web. On servers section change the IIS.

查看更多
Emotional °昔
4楼-- · 2020-08-17 07:01

Project Properties -> Web -> Servers -> Change IIS Express to Local IIS -> Check Apply server settings to all users -> then Project URL to http://localhost/Example (your project)

Then build your project.

查看更多
登录 后发表回答