I'd a HD problem in machine where my Intranet IIS server was installed and I've reinstalled all the software. I've restored the site data into new IIS but now, when I type the server address in a browser in a client or even server machine, it doesn't find the page ("Default.aspx"). I can allow "Directory browsing" and click the file but, obviously, I don't want this alternative, neither obligating users to type "Default.aspx" in the end of the URL.
Maybe it's a very simple configuration, but I've cannot found it in IIS.
Put the following in site's or application's web.config file:
<system.webServer>
<defaultDocument>
<files>
<add value="~/Default.aspx"/>
</files>
</defaultDocument>
</system.webServer>
When you select your website or application in the left panel, there is an icon named "Default Document" on the middle, under IIS title. That is where that configuration is made from IIS Manager. Current default documents are listed and new ones can be created by clicking Add link on the Actions panel on right.
Had the same problem in MVC project where I have put a default.aspx in the root
It was not enough to only set web.config
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="Default.aspx" />
</files>
</defaultDocument>
</system.webServer>
Also had too add
routes.IgnoreRoute(""); in RouteConfig.cs
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
I followed the guide: http://weblog.west-wind.com/posts/2013/Aug/15/IIS-Default-Documents-vs-ASPNET-MVC-Routes
I was looking for the answer of same question. But these line helped me to achieve goal.
<system.webServer>
<httpRedirect enabled="true" destination="/Pages/ABC/xyz/" childOnly="true" />
<defaultDocument>
<files>
<add value="~/Default.aspx"/>
</files>
</defaultDocument>
</system.webServer>
Related
I have followed the instruction reported here :
https://www.c-sharpcorner.com/UploadFile/francissvk/set-default-page-for-a-website-in-iis421/
What i would like to achieve, is that when user try to visit my site : "https://mysitename.com" it should be redirected to the home page ( "https://mysitename.com/pages/home.aspx").
I don't want to create a root Default.aspx page only to do the redirect, i would like to achieve this behaviour through Web.config.
As said, i tried the instruction in the above link, buy also tried the many solution proposed on this site that more or less suggest to add this configuration to Web.config :
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="/Pages/Home.aspx"/>
</files>
</defaultDocument>
<handlers>
I have tried different variation of the path, i have tried :
<add value="/Pages/Home.aspx"/>
<add value="~/Pages/Home.aspx"/>
<add value="./Pages/Home.aspx"/>
<add value="Home.aspx"/>
But allways i get this message error :
403 - Access denied.
If i manually enter in the browser the full page url "https://mysitename.com/pages/home.aspx" then i get no issue (just to point out that the page exists and is working)
I don't understand what i am missing in the configuration
A default page or DefaultDocument in IIS can't do what you want.
It is a feature that defines which document is loaded when a user requested a URL pointing to a directory on the server without specifying an actual page.
The value field should be the name of a file in that directory such as index.html or home.asp, it can not point to files in other directories.
In your case you may be able to use the builtin HTTP Redirect feature, in the GUI enable it and point to 'pages', also check the Only redirect requests to... checkbox
In your root web.config this may look like this:
<system.webServer>
<httpRedirect enabled="true" destination="pages" childOnly="true" />
<defaultDocument enabled="true">
<files>
<clear />
<add value="Home.aspx"/>
</files>
</defaultDocument>
</system.webServer>
Another option is to use the IIS Rewrite Module which allows you to create more complex rules on how to redirect and rewrite requests. It should be faster because it does work without a HTTP redirect which does back to the browser, but you first need it install it and understand how to use it.
I'm trying to use the Certify SSL Manager to configure SSL certificates from Let's Encrypt on my IIS server, but it fails during the check.
https://dev.mywebsite.com/.well-known/acme-challenge/configcheck/
This works:
https://dev.mywebsite.com/well-known/acme-challenge/configcheck
https://dev.mywebsite.com/.well-known/acme-challenge/test.txt
So I assumed it's the . before well-known. But the fact that test.txt works confuses me.
I've already configured the directory according to this discussion:
https://github.com/ebekker/ACMESharp/issues/15
I have a bunch of rewrite stuff in my web.config, but even if I remove that section completely, it still fails.
Perhaps check if the acme-challenge web.config contains a conflict within the handler section. Do so by opening IIS manager, find the acme-challenge folder en double click the handler mapping icon. In my case, this resulted in an error.
The problem I ran into with the default web.config in the acme-challenge folder was that the applicationhost.config contained:
<section name="handlers" overrideModeDefault="Deny" />
The handlers section in the acme-challenge web.config therefore was not allowed with the result that the challenge failed. In this case the solutions were:
Change applicationhost.config line to:
<section name="handlers" overrideModeDefault="Allow" />
Or ...
Remove the handlers setting from the web.config in acme-challenge folder.
The applicationhost.config can be found here: c:\windows\system32\inetsrv\config
The configcheck url is a file, not a directory. Make sure that file exists on disk (i.e. C:\inetpub\wwwroot\.well-known\acme-challenge\configcheck) in your webroot. Then try to load your links with this barebones web.config in your website root directory (if using ASP.NET):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="." mimeType="application/unknown" />
</staticContent>
</system.webServer>
</configuration>
If that works, try slowly adding back in your web.config sections including routes/rewrite until you figure out what's causing the problem.
If using ASP.NET Core with a wwwroot folder hosting your static files, you'll have to modify your config in Startup.cs instead:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
string filepath = Path.Combine(Directory.GetCurrentDirectory(), #"wwwroot/.well-known");
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(filepath),
RequestPath = new PathString("/.well-known"),
ServeUnknownFileTypes = true
});
// ... your other startup code here
}
I had to modify the web.config as follow to fix the error:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="*" mimeType="text/plain" />
</staticContent>
<handlers>
<clear />
<add name="StaticFile" path="*" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="true" preCondition="" responseBufferLimit="4194304" />
</handlers>
</system.webServer>
</configuration>
I have a site/application I would like to load in IIS. The root of the folders contains a web.config and index.asp. The sub folders are asp, scripts, styles, images.
I add Add Web site in IIS, define the physical path to the location of the index.asp, assign the IP address for host name I tried local host, IP, and leaving it blank. When I click on Browse Website I receive a HTTP 500 Internal Server Error. IIS is running and the Web Site is started in the Manage Website menu.
If I write a short index.html hello world page and set it as default document it displays ok. When I change default document back to index.asp I get the 500 error again.
Could someone give me a tip on how to proceed?
Here is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<identity impersonate="true" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="index.asp" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
This is going to be a guess at best, since a 500 can mean anything without a sub-status code. It probably is due to configuration inheritance. index.asp is already in the default list of default documents at the server level. By adding index.asp, it may be causing a unique hey violation when the configuration inheritance is flattened into the effective configuration.
Suggestion:
Add a <clear /> element right above the <add value="index.asp" /> and try again. Otherwise, we will need to go get the sub status code of that 500 to get more information. The IIS log usually contains the sub status in the sc-substatus.
Resulting Configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<identity impersonate="true" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.asp" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
If this works, then the reason it originally works with index.html because index.html is not in the default files list.
Additional Note
The other thing I can think of is that impersonation being enabled. If you are running the application pool in Integrated Pipeline mode, you'll need to turn off integrated mode configuration validation. More information can be found here: Integrated Pipeline mode configuration validation.
New Resulting Configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<identity impersonate="true" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="False" />
<defaultDocument>
<files>
<clear />
<add value="index.asp" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
I'm trying to download the bootsrap fonts from a container I have in a site hosted by OK Hosting. I can download the font manually but when using it in a CSS on a page hosted in another server, it fails because cross site access is disabled.
I know OK Hosting uses IIS but they give you a web based control panel.
How do I enable cross site access?
Ok, you just have to add a file called web.config at the root of your site with the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
You might also need the following just below the Access-Control-Allow-Origin.
<add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
I am trying to block all access to the admin url for Umbraco (v7.2.8) for security reasons. I have the below in my web.config file, but it does not work. It is blocking all access to that url, even from the specified IP. I am running this locally on my machine from Visual Studio, so I am not sure what IP the site thinks I am coming in on, but I have tried all of them. Does this web.config look ok?
<rewrite>
<rules>
<rule name="Restrict URL" enabled="true" stopProcessing="true" >
<match url="^umbraco($|/)"/>
<conditions logicalGrouping="MatchAll">
<add input="{REMOTE_ADDR}" pattern="^192\.168\.8\.100$" negate="true" />
</conditions>
<action type="Redirect" url="/no-access/" />
</rule>
</rules>
Any pointers would be greatly appreciated! I will be deploying this to Azure eventually but wanted to get this working first. Perhaps it's because i'm running it locally?
EDIT: I have tried the ipSecurity solution but receive the below error. I have installed the IP Security component for IIS. I am running the site from Visual Studio so I am not sure I can test it from here on the express service that VS uses? I have also changed to 'allow' in the following file;
%windir%\system32\inetsrv\config\applicationHost.config
This is easier to accomplish with system.webServer >> security >> ipSecurity settings in the web.config inside a location element:
<location path="umbraco">
<system.webServer>
<security>
<ipSecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="192.168.8.100" />
</ipSecurity>
</security>
</system.webServer>
</location>
See IIS IP Security more more details. IP Security is enabled by defualt on Azure WebApps.