We have a few sites that are all controlled via one CMS, even though they have their own domain name. They are all hosted under the one account.
I want to set the default page to index.html on one of the domains via web.config
So for example, with abc.com i want it to default to abc.com/index.html but leaving the other domains as they are.
While I can set the default to index.html it seems to break the other sites, as they redirect back to this on every occasion.
Try to wrap redirect rule with location element and specify your domain in the path attribute.
UPDATE
I think it should be something like this:
<configuration>
...
<location path="http://abc.com">
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.htm" />
</files>
</defaultDocument>
</system.webServer>
</location>
...
</configuration>
Related
I got a website published to server under 192.168.2.3.
I want access to the login page without including the full URL, I want it to be done by just entering URL 192.168.2.3, then after processing it become 192.168.2.3/login.aspx.
The problem I currently encounter is that it always goes to default.aspx.
I had tried to add some code at web.config and it just came out as the error shown below.
<configuration>
<appSettings />
<connectionStrings>
<add name="CompWebConnectionString" connectionString="Data Source=TDSPWEBSVR\SQLSERVER2008;Initial Catalog=CompWeb;User ID=sa;Password=tdspp#ssw0rd" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<defaultDocument>
<files>
<clear />
<add value="TechnicianProgram/login.aspx" />
</files>
</defaultDocument>
On your site in IIS one feature is Default Document. Check what has been set there. You may want to remove everything but the required login page path which will enable IIS to return the login page if the request URL does not specify a specific path.
This setting will update your web.config file with the values something like below-
<location path="folder1">
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
</location>
I have a website developed in ASP.NET. I have it hosted in IIS and say the url is www.web.com. Whenever I request for this page by typing the URL in the browser I am redirected to the login page with URL like this www.web.com/Login.aspx?ReturnUrl=%2f.
I have added the following in web.config so as to make Default.aspx as my Default page.
<defaultDocument>
<files>
<clear/>
<add value="Default.aspx"/>
</files>
</defaultDocument>
Also,
<forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx">
The pages are present on root folder, so I tried few things already mentioned here. Is there anything else I am missing ? A direction towards a solution or any links would be helpful.
Edit: The website redirects to Default.aspx when run on localhost
A couple of minor differences, but may help. I also assume you are using IIS 7 or higher.
If they are at the same folder level, you can try:
<forms loginUrl="Logon.aspx" defaultUrl="Default.aspx"/>
You can try:
<defaultDocument enabled="true">
<files>
<clear/>
<add value="Default.aspx"/>
</files>
</defaultDocument>
I like to secure all aspx files in a folder ~/Secure/ secure such that specific IP addresses can access the folder's aspx files. I added the following web.config file to the folder, hoping that it adds to the parent web.config:
<configuration>
<system.webServer>
<security>
<ipSecurity allowUnlisted="false">
<clear/>
<add ipAddress="192.168.100.1" />
<add ipAddress="169.254.0.0" subnetMask="255.255.0.0" />
</ipSecurity>
</security>
</system.webServer>
</configuration>
The problem is that I get this error when I try to access to any of the aspx pages in the folder:
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
What does it take to make this idea happen? I like to just include one web.config file to a folder and that enforces the IP address authorization. I like this idea, since it is no-code and config only.
You cannot do it in the website web.config only.
If you can use IIS manager:
Open IIS Manager, locate the site, click on the folder you want to protect, then click on IP address and Domain Restrinctions.
Also click on "Edit feature settings" in the right Actions panel" to specify actions for unspecified clients (i.e. Deny with Forbidden, or simply Deny With Not Found).
This will generate the right configuration for you.
In your root web.config use the location element:-
<location path="Secure">
<system.webServer>
<security>
<ipSecurity allowUnlisted="false">
<clear/>
<add ipAddress="192.168.100.1" />
<add ipAddress="169.254.0.0" subnetMask="255.255.0.0" />
</ipSecurity>
</security>
</system.webServer>
</location>
I have an IIS website running an ASP.NET site but it has multiple applications running under it (a virtual directory with separate app pools basically).
Well - I need two separate applications which point to the same root folder director but I want the apps to have separate default documents. The reason is because this is how it is configured in production and this is on my development box.
The problem is that IIS keeps giving me the SAME default document for both apps (which are separate virtual paths and separate app pools just same physical location). How can I overcome this or can I not in IIS7?
I am going to be re-writing the whole thing and it will not be done this way in the furture...but until then I need to fix some bugs and want a local dev environment. Help!
In order to accomplish this and preserve the setup implemented in our sites I needed to add a location tag around the System.WebServer element in the root site web.config and specify the default document in there as follows where the path is the VirtualDirectory/Application name:
<location path="VirtualDirectoryName">
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Document.asp" />
</files>
</defaultDocument>
</system.webServer>
</location>
<location path="VirtualDirectoryName2">
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="AnotherDocument.asp" />
</files>
</defaultDocument>
</system.webServer>
</location>
I expected this would also map the default homepage as in http://localhost/ but it is not hit.
RouteTable.Routes.Add(new Route("{Keyword}", new HomeHandler()));
Question is of course why not? I would like to map the root to some other page.
I haven't tried this yet but try removing the default document from IIS's configuration. For IIS 7 this setting is in web.config:
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
</files>
</defaultDocument>
</system.webServer>
</configuration>
The answer is somewhat complex. It was on IIS6 and we had to add a specific property. I cannot really remember what we did back then but you can google it, that's how I found it.