14

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 ?

Ambika
  • 153
  • 1
  • 1
  • 7

3 Answers3

12

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.

Steven
  • 150
  • 10
5

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

StingyJack
  • 19,041
  • 10
  • 63
  • 122
  • status is coming as 200-OK .Can you let me know how can i use IIS server instead of IIS Express in Visual Studio 2015? – Ambika Jul 11 '16 at 11:45
  • The other answers cover how to setup Visual Studio Web Application Projects. If you do not see what they are explaining, then perhaps you can include a screenshot of your solution explorer (no code, just file names) so we can understand better. – StingyJack Jul 11 '16 at 12:03
  • Is the status 200 returned for all the resources (there should be several rows, not just one for the page) when you point your browser at a copy of your code published to a remote IIS? – StingyJack Jul 11 '16 at 12:03
  • @Ambika - if you create a new blank website project in VS 2015, and follow the steps above to use the local IIS, can you start debugging? – StingyJack Jul 12 '16 at 12:38
  • Thanks a lot ! I followed exactly what you told and selected Use Custom Web Server. It is now running fine.Thank you so much :) – Ambika Jul 13 '16 at 12:22
1

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

Mahdi
  • 3,199
  • 2
  • 25
  • 35
  • 3
    This option is discontinued since VS2013. When i right click on project, i see Properties Window and Properties Page.On any of these ,there is no Web option. – Ambika Jul 08 '16 at 12:37
  • Have you seen this [link](https://msdn.microsoft.com/en-us/library/ms178108.aspx)? – Mahdi Jul 08 '16 at 13:18
  • @Ambika if you do not see the Web tab in the project properties, then you are not using a Web Application Project. – StingyJack Jul 08 '16 at 17:51
  • Yes i am not using Web application. I have a Website which i need to run using Local IIS. Is it possible? – Ambika Jul 11 '16 at 12:59
  • @Ambika - updated my answer. Sorry for missing that part which you had clearly stated. – StingyJack Jul 11 '16 at 13:44
  • @StingyJack Thanks for the answer. But, can you give me an example of what the URL should look like which we have to enter in The URL Text box when we select Use Custom Web Server. Suppose i have created an application named "Test" in IIS,what should be the URL? – Ambika Jul 12 '16 at 10:28
  • Also, when i right click on the website in Visual Studio 2012, i see there is a Virtual Directory created.But, VS2015 has no such Virtual Directory. – Ambika Jul 12 '16 at 10:32
  • @Ambika - That is a different question, but there is an answer here that may help. http://stackoverflow.com/a/32799333/16391 – StingyJack Jul 12 '16 at 12:53