How to create Application in the IIS Default Web Site root (virtual path : '/')? - asp.net

Context
I have an Asp.Net MVC application. I would like to deploy it to an IIS (Windows Server 2016). I do not care which will be physical path, but I would like to access to the application in the virtual path '/'
(I am using Package web publish method, because no online access to the server, but I think this question is on IIS/ASP and not about publishing. I clearly miss some basic concept about IIS/ASP.)
What I've tried
1) When I try to create an Application in IIS then the dialog forces me to add an application Alias, which becomes the part of the virtual path. So regardless the physical path now the the url will be
myserver/myapp/mypage instead of myserver/mypage
which is not what I want. I would like to access to the page as myserver/mypage
2) If I simply deploy the app under wwwroot then it will appear as myserver/mypage it seems to be working, but where is the "Application" this case? (see picture).
Question
Maybe I missing something: Is this the Default Web Site is an "Application" in its own right? How to configure then its Application settings? If not, then how can I create an Application which's virtual path is '/'?

If I have understood your question correctly, you want to access the application as servername/pagename. In order to do so, do not create an "application" or "virtual directory" under a "website". Instead, directly host the content under Default website. You can change its path under "Basic Settings" and point it to your content folder.
You can also create another website at port 80 and point it to the location where your content is present. However, you will not be allowed to create 2 website with the same IP-port-hostname combination. You can solve this problem further in 3 ways.
If Default web site is not in use, then instead of creating another website, click on Default website, select basic setting from right hand panel and change the path to application content folder.
If Default website is in use, then create another another website at port 80 with a hostname.
If you do not have a hostname and are accessing the application using server-name, then you will have to modify the port to 8080 or something like that.
Refer my blog - https://blogs.msdn.microsoft.com/parvez/2016/07/27/iis-bindings/ for more information about IIS bindings

Related

How to use host headers in IIS for a web application?

I have configured a website in IIS with a host header, so that I can call the url customhostheader/ and the website will be shown.
When I try to publish my web project, I get the error that some sections in web.config are registered as allowDefinition=MachineToApplication. But I cannot convert the website in to an application in IIS. I can only convert virtual directories into IIS applications, but I don't want the much longer url http://customhostheader/virtualdirectoryname, I prefer to have just http://customhostheader.
Any ideas what I could do?
Thanks.
Add an application with the name customhostheader which is pointing to your published code (parent of bin folder)
To do this
Right click on "Default Web Site" in IIS and select "Add
Application"
Give alias as customhostheader and provide the path to your application.
Edit based on the comment
Each website by default contains an application. So we just needs to make sure the path of the website is correct.
The following two points should be enough to set up the correct path
The path should be parent of bin folder
The web.config should be present on the path
The default document can be set through the IIS or web.config

Why is a Web Site project not serving pages except through IIS?

I have inherited quite a complex web site project, and when I run it in VS 2012 under the default "Use default Web server" setting for "Server", it serves the login page correctly, under the base URL http://localhost:45632 and I can log in nicely. Then, when I click a menu item with the URL http://localhost:45632/Apps/Visitors/General.aspx, I get a good and plain 404.
If I then create a web site (not application under the default site) for it in IIS 7.5; set the physical directory to the project's source folder; give it a host name, xtjethro.local, and edit my hosts file to point that host name to 127.0.0.1; set the web site project to use a custom server, with a base URL of and finally, browse the site from its context menu, it serves its pages under the base url http://xtjethro.local/ instead of http://localhost:45632, everything works fine.
Then, if I set the web site project to use a custom server with a base URL of http://xtjethro.local, and restart VS2012, running it as administrator, everything works from there as well.
I would like to know why http://localhost:45632/Apps/Visitors/General.aspx doesn't work under VS2012, but http://xtjethro.local/Apps/Visitors/General.aspx does work under IIS.
The Visual Studio development web-server usually runs the site under a virtual directory which matches your project name. That would mean that the URL of your page should be http://localhost:45632/YourProjectName/Apps/Visitors/General.aspx. If you create an application under the default site in IIS, you will probably see the same problem.
You'll need to change the way your links are generated. Instead of using /Apps/..., use ~/Apps/... - ASP.NET will automatically resolve ~/ to the base path of the site.

deploy asp.net project on another computer

Just to begin I am a beginner in ASP, and havign some difficulty in deploying my first application.
I made a asp.net project in VS2008, and I ws trying to deploy it on another machine and following are the steps that I did:
right clicked on website and published set loaction to c:\inetpub\wwwroot and pasted my app to this folder.
Then I went to control Panel- admin tool- IIS and there it showed the website which I copied then went to its properties added documents, set ASP>NET version, it was blank by default. Then edited the configuration and under authentication changed its mode to none.
And then when I cick on the app in IIS and browse it showed the desired output, but I need to know how to open the same app in browser.
Thanks
If I've understood this correctly - it does depend on how the website has been set up in IIS. At it's most simple it would be
As the default website
http://[external IP of webserver]/default.aspx
As a virtual under the website
http://[external IP of webserver]/[virtualName]/default.aspx
Assuming there is a file called default.aspx (insert your own)
if default.aspx is specified as a default document for the site
http://[external IP of webserver]
http://[external IP of webserver]/[virtualName]
if you are using binding to a specific IP and or port (look in IIS, left handside at the binding link - see image below)
http://hostname: optionalpost
Apologies if I have misunderstood
EDIT
To check whether the site is active at all and to get a better idea of what the external URL is then on the left hand side of IIS will be browse to website. Click this to check whether the site comes up at all.
If it does then the URL should be obvious. It could be one with a host header i.e. looks like a normal URL i.e.
http://mytestsite.com
If it is in this format then you may not be able to browse externally if you can't resolve this hostheader to the IP of the box. To get around this then edit you host file and add a mapping from the url to the external IP of the box.
Host header is at following in windows 7 (or windows generally i think)
C:\Windows\System32\drivers\etc\hosts
Please back this file up before editing it

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)

Run ASP.NET application as Default Web Site on dev machine

I am trying to run my ASP.NET Web Application Project in my Local IIS Web Server instead of using the Visual Studio Development Server. It seems to only allow me to run my application in a Virtual Directory off of the Default Web Site. However, I would like to run the application in the root of the Default Web Site itself.
I go into the properties of my project, go to the Web tab, click the User Local IIS Web server radio box, and change the Project URL to http://localhost/. However, when I attempt to save, it tells me I need to configure the Virtual Directory, although I am not using a Virtual Directory.
Has anybody made this work before? Thanks!!
It sounds like localhost port 80 is already in use.
IIS creates a default web site that listens on localhost port 80. Have you disabled that before trying to add yours?
Another approach is to have your site listen on a different port, 81 for example.
So far I used a Post-Build event to copy the contents of my project to c:\inetpub\wwwroot\ and I set the Start Action's Start URL to http://localhost/. Not very elegant, but it gets the job done. I would love for somebody to include a more elegant solution.

Resources