How to setup virtual application with sub domain name? - iis-7

I have a site called: testsite. Under that site, i want to create 1 virtual application called: app1. Then the url for the new application will be: testsite/app1.
Under app1 i have one page: default.aspx. testsite/app1/default.aspx. On page load of default, if i redirect to itself: Redirect("default.aspx"); it went for testsite/default.aspx instead oftestsite/app1/default.aspx.
I do not want to convert it to virtual directory for some requirements reasons.
Anyone can help me? I want it to redirect to: testsite/app1/default.aspx without modifying the code. Since in the future i might have more than one application.

Do you have a virtual directory or a application? If you have a application you just need to do this:
Response.Redirect(~/default.aspx)
In this way you always go to the root of the application.

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

Azure multiple websites, subdomains and virtual directories

I have a front end application and an admin application in a dedicated windows server on IIS. The admin has an images virtual directory pointing to the front end images directory so that any images uploaded through the admin uploads to the front end directory. Also the admin is a sub domain of the front end website. I am trying to replicate this structure in Azure.
So far what I've tried:
Created two different web apps and mapped the external domains say, www.contoso.com and admin.contoso.com with no problem. But if I need to create a virtual directory in the admin web app, it doesn't allow me to reference anything outside the site\wwwroot folder of the admin web app.
Created two directories in the same web app but cant find a way to map www.contoso.com and admin.contoso.com to two different directories in the same web app.
Uploaded the front end to the site\wwwroot and created a sub directory called admin and mapped www.contoso.com and admin.contoso.com to the same web app and used url rewriting to point the admin sub directory to admin.contoso.com. But still can't find a proper way to add a virtual directory in the admin to point to the front end.
I am using the new portal and the applications use ASP.NET MVC, .NET 4.5 by the way.
Can anyone please point me in the right direction of how to manage and configure multiple websites with subdomains and virtual directories?
Try this - in your 1st configuration. Go to Azure Web apps settings -> Application Settings -> Virtual Applications and directories and setup the physical path of the new folder(Other than the site/wwwroot). Also check the Application checkbox and restart the website once.
I've used the third approach from my question where I created a sub directory for the admin. I would still like to know how this can be done using other approaches.
So I had created a virtual application for the admin already which is mapped to the subdomain. I was trying to add a virtual directory for admin/content/images/frontend to point to the front end site\wwwroot\content\images. I was doing this in one single line of virtual directory setting which was complaining that the path was invalid. So I had to create a virtual directory for each admin/content mapped to site\wwwroot\admin\content, admin/content/images mapped to site\wwwroot\admin\content\images and then finally admin/content/images/frontend mapped to site\wwwroot\content\images which worked.

Getting 404 error in IIS when calling asp page

I have a problem with my asp.net 4.0 application. When I call it on the server, it works, but when I call it from outside the server, it gives me a 404 error.
The link I call the asp.net application from is the good one. Other asp.net 4.0 applications are working fine when called from outside the server. The other applications are in another folder though, but I do not see why it would work under a folder and not another one. There is no IP restrictions on the applications.
Anyone got that error int eh past?
Thanks
EDIT:
The app is configured as an asp.net 4.0 application. it is stored in a virtual directory.
This link works:
http://localhost/Phonebook/PhoneBook/default-defaut.aspx
this link does not : https://www.test.com/Phonebook/PhoneBook/default-defaut.aspx
A coworker and me found the answer. It's because the server I called on my url was supposed to have a rule redirecting the browser to the right url. So IIS7 on my test server was setted up right.
Theres several things to check.
That test.com is even going to your server. Put a file in the root directory 'test.txt' that IIS lists as the root folder for your site. ensure you can get to it.
Once you verify your root site folder WORKS for ex., www.test.com/test.txt then ensure you have a virtual directory /phonebook that contains a folder phonebook within it.
Seems overkill to be having to folders named phonebook. Try taking one of them out and pointing your web application to your
c:\whatever\phonebook\phonebook folder.
Make sure port 443 is bound to your app if you're using https, that could be your problem.

Nested virtual directory or application within sitecore site, is it possible

I would like to nest asp.net web app within sitecore site, something like this:
<sitecore web root folder>
.
<virtual directory/app folder>
I want to access sitecore site by using following url:
http://<whatever site name>
and I would like to access web app by using following url:
http://<whatever site name>/<whatever virtual directory/app alias>
Is this possible?
I tried it but when I try to access my web app (not sitecore) then web app complains about missing sitecore.
I believe that is because now I have two config files ans when accessing web app iis/asp.net processing first sitecore web.config.
Right, your assumption is correct. See Creating a project in a virtual directory under Sitecore root article for more information about this kind of setup.
You should be able to create a virtual app under a Sitecore root path. Because its an app it will use its own app pool and you can have a web.config for it. I guess the physical files will be OUTSIDE of the Sitecore Website folder but the from a URL you can make the virtual app located anywhere below the Sitecore root.

ASP.NET site inside a virtual directory

I am currently putting a new version of my site online. I would like to retain the old site (for purposes of read only access) and have been directed to place it within a subfolder inside the directory where the site use to live. e.g.
www.example.com needs to be moved to www.example.com/old and the new site needs to be moved to www.example.com
Unfortunately I get the classic ASP.NET error when attempting to piggy back sites that each have their own web config.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
How can I compeletly seperate off the new site and access it via. www.example.com/old without ASP.NET trying to trickle down through my directories and find the main sites web.config?
Thanks!
Giving the site its own AppPool should work.
You can do this by creating an AppPool and then on the virtual directory in IIS setting the app pool to your new one in the properties.
Make sure that the virtual directory is an application and not just a virtual directory.
You may try the following setting in the site contained in the virtual dir:
<location inheritInChildApplications="false">
Rick Strahl has the same problem and describes his experiences on his blog.
Didn't try it out myself, but found other blog articles which use it successfully with IIS6.
I've tried both creating a new App Pool on the site. That's didn't work -- same errors. I also added the inheritChildApplications attribute directive in my web.config. That didn't work either. The only way I have been able to achieve what I needed was to add a new subdomain in an entirely new folder and put a redirect to it in my www.example.com/old page to old.example.com.
It's not what I was looking to do, but it solved the issue.

Resources