Having more than one site in IIS7 - iis-7

suppose I have two domains
www.site1.com
www.site2.com
To publish them on the same IIS server I have created 2 virtual directories /site1 and /site2.
How can I associate every name with its own virtual directory?

Rather than set them up as virtual directories, set each site up as their own Web Site. Then edit the bindings of each Web Site, and specify the appropriate domain name for each site

Your question doesnt seem to make sense,
'How can I associate every name with its own virtual directory?' - what does this mean what do you mean by name?
Also you dont have to make 2 VD's for 2 websites. Just make 2 websites...and use one dns for each one.

Related

IIS8 - Add a virtual application followed by language keyword in multilingual site

We have a situation in IIS8 to add a virtual application followed by language keyword in a multilingual site. For an example, following are the site links that we wanted to add 'tickets' as a virtual application followed by language code.
https://www.abcd.com/en-sa/tickets
https://www.abcd.com/en-ae/tickets
https://www.abcd.com/ar-ae/tickets
In general, virtual applications will be accessed right after the root domain - https://www.abcd.com/tickets but requirement is slightly different here. Can anyone suggest a solution?
I see two approaches:
One is to add a virtual directory in IIS, for each language level and point that to a single implementation. In the code, you can check the language from the URL and set the culture based on that
Example:
https://www.abcd.com -> points to single site in IIS
In that site, add en-sa and other langauges as virtual directory, all pointing to single directory on disk.
The other approach would be to use ASP.NET routes in a single application, where URLs don't need to actually exist.

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

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

IIS server routing and redirection

In our IIS server we created 3 websites, so under the folder Sites we have Default Web Site, Site1, Site 2. under Default Web Site we have many many applications and one of these applications called "Main"
Also we have 1 domain name like "http://www.ourdomain.com"
How can I do the following
If the user wrote http://www.ourdomain.com or http://www.ourdomain.com/main, then redirect to Default Web
Site/Main
If the user wrote http://www.ourdomain.com/Site1, then to show the content of Site1 and not an application inside the Default Web Site
If the user wrote http://www.ourdomain.com/Site2, then to show the content of Site2
Our Admin he used the HTTP Redirect and he put the url http://www.ourdomain.com/main so everything is redirecting to main
Also, is it possible to use this configuration site1.ourdomain.com instead of http://www.ourdomain.com/site1 ? and how if yes?
Forgive me for my question, I have no experience about how to work on these things in IIS
Option 1
To get site1.ourdomain.com you just need to set the host header in IIS to use this subdomain. Right click the site in IIS, click "Edit Bindings", either add or edit an existing binding to use the subdomain. I would strongly recommend against having three separate sites in IIS if those sites are subsites.
Option 2
Your other option would be to make the subsites areas in MVC in one project.

Setting up asp.net test server

I am creating a website in asp.net MVC 4 and am wondering the best way to set up a test server?
I am doing this from home and would like a way for my friend to test my code from a different location (his home). What would the best way to go about this? Build a local server that he only has access to? VMWare? Online web hosting?
One solution would be to use a VM and set up a server.
NOTE! that this would require your friend to redirect your IP Adress to the host name you will set for your website on the IIS of your VM.
He can easily do that by changing his Hosts at C:\Windows\System32\drivers\etc
Another option would be actually to purchase a domain (that you will need anyway eventually)
The purchase a hosting package (that you will also need anyway eventually).
Then setup your website on a sub domain in that hosting server e.g. dev.myDomain.com

create a web site using Microsoft.Web.Administration.ServerManager.Sites.Add

I want to create a web site in my setup project using Microsoft.Web.Administration.ServerManager.Sites.Add method, but it needs a physical path of the web site to be specified. I want the web site to be created at it's default location. How can I find out the physical path of the default location?
Typically when adding a new site this would have a different directory to any pre-existing site. For example IIS comes preconfigured with "Default Web Site" site and the physical path for this typically points to:
%SystemDrive%\inetpub\wwwroot
You would not normally create a second site that also points to that directory. As an example you might configure the second site to point to (or any other preferred location):
%SystemDrive%\inetpub\wwwroot_secondsite\
That said, if you really want to have multiple sites with the same physical path then you should be able to use Microsoft.Web.Administration.ServerManager.Sites property to enumerate all current sites and from there extract the physical path.

Resources