Using IIS Server instead of IIS Express in Visual Studio 2015 - asp.net

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 ?

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.

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

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

Related

How can I get Visual Studio to automatically attach debugger to web Site not Application?

I have a web application required to run as a Web Site (root application). This is due to it being a multi tenant application that uses the urls sub domain prefix to know which client is accessing it. I create the site in IIS 10 setting the physical path to my Visual Studio 2017 .NET 4.5 MVC application and the site works fine.
I open the web project properties and under Servers choose Local IIS setting and set Project Url to the site I just created in IIS. Visual Studio then forces me to create a Virtual Directory for the Project Url, to save it, which then creates a Web Application under the default web site. You can't set and save the Project Url without being forced to create the virtual directory.
Now when I start debugging Visual Studio attaches to the Web Application not my web site so my breakpoints never get hit. If I manually attach to the w3wp process where the web site is running I can debug. I had this all working fine prior to recently switching to Git causing me to reconfigure things and I can't recall what I did to make it work.
How can I set the Project Url on web properties page without being forced to create a virtual directory? Or how do I make VS automatically attach to the Web Site and not Web App I was forced to create?
This blog might help: How to Debug Your ASP.NET Projects Running Under IIS
If your project is a website and not a web app, then here are the steps to configure it to use IIS when debugging. This assumes you already have IIS set up and hosting your project.
In the solution explorer.
Right-click on your project node and navigate to "Property Pages".
Navigate to "Start Options" item in the left pane.
In the "Server" section make sure "Use custom server" is checked.
In the "Base URL:" field put in the address you have mapped to your project. (Usually the address you put in your hosts file)
I finally discovered that setting the Servers 'Project Url' in the web projects properties page to 'http://localhost/' does not force you to use the 'Create Virtual Directory' to save the changes. You can't even change the default port here without being forced to create a virtual directory.

Published website ASP.NET with IIS

I have just completed my website and I started working with IIS it works fine when I put all my file without published. I copy the whole website to wwwroot inside my folder as I said It works fine but when I tried to work without code behind page it didn't work I published website from VS. and I copy my published file to the same folder but it doesn't work.
I received this error:
Eval is not declared. It may be inaccessible due to its protection level.
I don't want to put my code behind page. How can I run my published pages?
First, when you publish your web project, their are no code behind pages.
Do this, set a directory and publish your site in it.
Now cmd-> intemgr->
site-> -> add web site->
give site name and select an application pool, then set the physical path to the directory where your application is published, if necessary change the port to something like 50 because 80 is a standard port for http. Hit ok. Your site is ready.
Please check in application pool that your application pool is set to .Net framework version V4.0 (i mean the version compatible to your app ).
just click to browser the site, please do check the uri you can see the port number also

asp .net 4.0 app on IIS7 Error 404.17

I am having a problem setting up a website under IIS 7. I have created an application and the application pool for the application. Application pool is using .Net Framework 4.0 as my .net app is written in .Net Framework 4.0. Application pool is set to use classic Pipeline Mode. MIME Types have been automatically added to .asp & .aspx.
When I run the website windows explorer is showing me "View Downloads" and trying to download "application name localhost" when it downloads the file I notice that its the html of my default.aspx. I have checked Default Document and it contains Default.aspx.
If I remove .asp & .aspx MIME Types then I get an error: HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler.
I have seen this problem many times. IIS is not serving aspx pages and most likely is not running for the entire server or that site.
For the entire server: Check to see if iis world wide web service is running.
For the site alone: Hit run inside IIS.
You can easily know if IIS is running properly by going to IIS and hit the browse option from inside a web site.
With the data you have put these are the things I would try in order if I were you:
Check in Server Manager/ Features if ASP.NET is installed (ServerManager/Roles/Web Server(IIS) look for ASP.NET
Check IIS Manager if everything is ok by:
Try to browse a test.html file to see if you are able to browse normal
Check Basic settings by clicking Test Settings
Check Handler Mappings to see if aspx is there.
Try to browse a sample test.aspx page with test data.
Check Application pool settings.
Reinstall Framework 4.0
Reboot machine ( a classical)
If you gave us more info and/or the ouput of my proposed tests maybe can help more. Good Luck :)
I had the 404.17 error happening on a server today. As you and cad mentioned, I checked the framework of the Application Pool that my site was using to make sure it was set to ASP.Net 4.0, and it was. What happened in my case is that my site was not using the application pool that I thought it was. My site was nested under another site, meaning my site pointed to a subfolder but another site was pointing to the root folder. Even though I had my site set to use the ASP.Net 4.0 Application Pool, the root site used a different Pool that had ASP.Net turned off, it was set to "No managed code". When I set the framework to 4.0 for the Pool the parent site was using, then my site started working.
In my case the solution was fixing the Handler mappings as explained here: http://forums.iis.net/post/1943489.aspx
IIS Manager->high-light you web site->click Handler Mappings icon on
the home pane->click Revert to Parent...
on the right Actions pane

How to set up a asp.net application on IIS

I've copied a whole folder which keeps a website inside from a web server to another computer.From the original server I can easily run the web application. Now I need to know what exactly I have to do in order to be able to run the application on the second computer too. I think there are some special considerations with IIS. What and how do I have to set up in IIS?
Follow these steps.
create a new site from left menu By right clicking and add new website.
Give physical path to that folder
Map with the site url
Give permissions to Directory as (like everyone)
Set up the default page if (index page is not present in the directory)
Set framework which ever you are using.
Install the IIS Windows component for whatever version of Windows you're using.
Create a new site in IIS
Point this new site to your web root
Configure DNS for the site (maybe using your hosts file)
There are some considerations to make depending on which version of IIS you are using. It would be helpful to know if you are using 6 or 7.
If you are under 7, you need to copy the site to your IIS directory (typically wwwroot) and then setup the basic settings in IIS by choosing your application pool and such. Application pools are typically (but not always) setup by .Net Framework. You may need to setup your default page and set it as an application. There are many blogs and sites out there that will tell you how to setup this basic functionality but are specific to your application.
For configuring IIS
1. Firstly, in Programs and features go to Turn on and off windows features...in that tick everything under IIS..go to sub folder and tick everything everywhere
Go to Internet Explorer> Setting> Internet Options> Advanced> untick Show friendly http error messages option
Go to IIS manager
a. In default application pool> advanced settings > Set true enable 32-bit program option
b. Go to Asp> setting> expand debugging properties> there will an option of error messages some 2nd last or last option that would be false...set it to true..apply changes
Run vbscript and asp only in Internet Explorer (edge 10 in developer options for pop ups)

IIS ASP.NET MVC3 doesn't show my website

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 visit
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 http://asp.net/mvc.
</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?

Resources