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.
Related
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.
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
I m having a ASP.Net Webapplication it accessed by from many geography like India,China&America.In that application's login page fields are username,Password & Geography.
Based on this login page geography option the application's functionalities will change in all page.
In this project,If we add a feature for Indian users but that will not required for other geography users,So we use some conditions like if The geography is India means Enable the feature others means disable it.
problem here it is, in all pages we need to use so many conditions check,some time it creates conditions check overhead.
So we planing for divide the webappplication in to separate applications based on geography wise.
What I planing is,
In hosting environment
1.Keep the same project into Three(India,China,America) Subdirectories.
2.In root directory we have login page only .So once user select the geography means we need to redirect the corresponding subdirectory.
By this way we can maintain the changes which made based geography as separate.
But My doubt is...
If we keep the project as Three(India,China,America) Subdirectories means each directories are have same files ,bin and webconfig file,So I think we cant maintain more than one webconfig file in hosted ASP.Net application folder.
This Subdirectories idea is possible or not in IIS hosting environment?
Is any other options are available?
Experts please share your valuable ideas.
Thanks in Advance
Ramesh
Good afternoon Ramesh!
If I understand your question correctly you currently have 3 separate web roots and you want to use these as separate web applications that will be served to users based on geography in some way. You also want to maintain individual web configuration files for each as well. If this is your inquiry then this set-up is definitely possible within IIS 7 and above.
To provide this functionality this you can do the following:
Configure a single main site within the IIS. This site can point to a web root or nothing. If it points to a web root, whatever web.config that exists will be inherited by the web applications we will add in the next few steps. Otherwise, the machine.config will be used.
Add 3 separate web applications underneath this main site. Make sure to add the root path of each application to use the respective 3 paths for your web roots. The web applications will by default inherit web configurations from the main site as mentioned earlier, but you can include a separate web.config within each of these web root folders.
I have two ASP.NET web forms application and I need to run them independently of each other. But for logistical reason of maintenance I prefer to have one as a Sub-folder of the other. Example:
c:\inetpub\wwwroot\MyAppl1
c:\inetpub\wwwroot\MyAppl1\MyAppl2
Each application has its own Form Authentication (different name log in pages)
First I create the MyAppl1 as web site and MyAppl2 as virtual directory. But then running a page in the MyAppl2 gives error:
The virtual path '/Site.Master' maps to another application, which is not allowed.
The above Site.Master is in c:\inetpub\wwwroot\MyAppl1\MyAppl2
Now I am thinking that maybe virtual directory was not the best approach. Can I create MyAppl2 in IIS as a separate Site pointing to a physical directory which is in sub-directory of another site?
In my ASP.NET 4 website most of source paths/references look like ~/Controls/etc..
When I transfer site to server ~/ starts to point to the root of my domain rather then to the folder where site is located hence all those paths become invalid.
How to fix this in one go without fixing references one by one?
is there something in web.config where I can set application path?
The ~ character is used to base paths from the application root, in this case, the root of your domain. What you can do, in IIS, is convert the subfolder to an application (essentially an application within an application), and this will force ASP.NET to use your subfolder as the root of the application.