IIS server routing and redirection - asp.net

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.

Related

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

Difference between creating my asp.net MVC web application ,under the IIS Default web site, or create it as a new web site

I have published my asp.net MVC web application under the “Default web site” inside IIS. I actually added two versions of my web application:-
one directly under the default website and it can be accessed by typing http://servername
one under presaging path , and can be accessed by typing http://servername/prestaging
so I got confused on which approach it is recommend to add my asp.net web application, and what is the difference between adding my web application under the default web site, or creating a whole new web site ?
Thanks
This has more to do with organization within your company's IIS structure than right and wrong. If the site you built truly is the only site on the server, putting it on the Default site is not looked down upon.
But if the application is a sub application of the default site, the latter approach is the more appropriate approach if you only get to access the site from the //servername URL.
If you have a separate domain, myapp.servername.com, you can install it into the default iis site and add a binding or you could create a whole separate web site.
Has more to do with your structure than right or wrong.
Edit
To answer your comment, creating the site under the default web site will make the URL in most cases be: 'http://myservername/MyApp'. Creating your own application would require (in most cases) a separate binding address, 'http://myapp.myservername.com' It is really only affecting the URL you place in your browser and nothing else. More complicated setups are possible, but for most cases, these are your two options.

How to base my ASP.NET website out of a specific URL directory?

I've got IIS 7 serving up my ASP.NET MVC website. It's the only site that I have configured in IIS. When I access the site, the site is based out of the root URL directory. For example, my site would be accessed like this: http://example.com/index.html
How can I configure the ASP.NET site to be prefixed by a specific URL directory? I'd like it to be something like this: http://example.com/application/index.html
Is this something I do in the ASP.NET configuration or within IIS itself?
You can create an "Application" for your site (right click on your web site in IIS Manager and choose "Add Application") and give it the directory name that you want. This way you can have, for example, multiple applications under the same domain e.g. http://example.com/application1/whatever and http://example.com/application2/whatever.
This article describes the differences between Sites, Applications and Virtual Directories:
http://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis

Sharepoint site as a subsite under a asp.net site

I have asp.net hosted at my domain which i access using a url like 'http://www.xyz.com. I have other web applications which are under the root web application in virtual directories which can be accessed using a url like 'http://www.xyz.com/subsite1 etc.
Now i want to have a sharepoint site as a subsite under my root website which i can access using a url like 'http://www.xyz.com/sharepointsite1.
I have installed sharepoint 2010 server.This installed a new website Sharepoint-80 and The central administration site. I have changed the Sharepoint-80 website setting to point to wwwwroot where my asp.net wesite and its subsite files are located. Now if i make a new site collection in my sharepoint site and it gets successfuly created. But when i browse it i get following error.
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
My webserver is also a domain controller. How do i resolve this issue? And how do i achieve the main aim of having a sharepoint site as a subsite under my main website?
Thanx
I don't think that is possible, unless you are using different host headers or you can write an HttpModule which would be complex in my opinion. Although reverse is possible, You can have a sharepoint site at / and then an ASP.NET site at /subsite
The reason is an IIS SharePoint website is different from IIS ASP.NET website. IIS SharePoint Website registers an extra SPRequest module which fetches the data from SharePoint content database. When you request / , it will always try to pull this data from the SharePoint Content database.
In your case, where you have changed the SharePoint-80 website to point to wwwroot, you have essentially removed SPRequest module from the pipeline. That's the reason you get the error, because its not able to pull the content from the database.
You should do the other way around. Change main site to Sharepoint site, and let your other asp.net application/site to be subsite of sharepoint.
You cannot do that. Simply because you're trying to encapsulate a cloud-based system into an internal IIS folder structure.
You can not add Sharepoint online page in an iframe because of the same origin policy that most of the sites on internet adopted this days. This is mainly for security reasons to avoid from web attacks like Clickjacking and XSS.
You can not add Sharepoint online page in an iframe because of the same origin policy that most of the sites on internet adopted this days. This is mainly for security reasons to avoid from web attacks like Clickjacking and XSS.
If you want to display the content of the sharepoint online into different domain, than try to use provider hosted app in windows azure or develop a Napa sharepoint hosted app which can make cross domain requests in REST or ajax

Orchard CMS - Can i Copy the website contents to another site? (First Time Publish)

I've setup Orchard on cms.mysite.com
I didn't set it up on www.mysite.com, because during the stages of when i configure my site for the first time, i don't want it being seen via www.mysite.com
I'm planning to follow these steps:
Configure my site via cms.mysite.com
Create another IIS website, running ASP.NET 4 on www.mysite.com
When the site's ready, copy the website contents (file sytem) to www.mysite.com
Remove cms.mysite.com
All future changes to the site (e.g by editors/authors) will be done on the main site (www.mysite.com)
This should work right - since all the content is stored in the database?
Or am i doing this the wrong way?
Yes, that should work perfectly fine.
But remember to change the base URL setting (in Dashboard --> Settings --> General) to the new URL.
And also make sure that the IIS App Pool (under which the new app runs) user account has read/write access to App_Data folder in the Orchard root.

Resources