I am running IIS 7.5 and in my VS2015 project I have set the start page, I also have set the start page using my webconfig file like so:
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="~/Page1.aspx" />
</files>
</defaultDocument>
</system.webServer>
But anytime I try to browse my site I get a
403 - Forbidden: Access is denied
Start --> Run --> inetmgr
Click Your Site
Click Default Document
Add whatevs the name of your start-up page should be
As far as your comment above, did you update the "Web" file in the root of the drive or the "web" file in the same location as your .aspx pages?
Related
Using an Apache Server you can set a file etag in the .htaccess file as follows
<FilesMatch "\.(jpg|jpeg)$">
FileETag MTime Size
</FilesMatch>
This is useful to stop browser caching of an image file.
Is there an equivalent setting that can be put in a web.config file?
My site is running on an Azure App Service
I'm not familiar with Apache Server, are you trying to disable cache for specific name extension files? if so, you can try below steps:
Open IIS -> output caching ->add –> put the name extension such as .jpg–> set prevent all caching on both user-mode and kernel mode. You can add more rules for .png .jpeg etc.
Also these are what the web.config looks like:
<system.webServer>
<caching>
<profiles>
<add extension=".jpg" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
If I misunderstand your requirement, please post more details information about etag.
I want to add a path mysite.com/_this when a request for this path is called I want to serve the json file that's under Sites/MySite/Content.
The caveat is I cannot implement this via code change. I need a way to implement this setup using the IIS CLI.
I have found the following article https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/iis-url-rewriting-and-aspnet-routing, but it's a little cryptic and hard to follow.
Windows: Window Server 2016 (1607)
IIS: 10.0.14393.0
In my opinion, the right solution for your issue is iis URL rewrite module.
If you did not install the url rewrite module you could download from the below link:
URL Rewrite
then add a rule in web.config file:
<rule name="Json Redirect" stopProcessing="true">
<match url="([\S]+[.](json))" />
<action type="Rewrite" url="folderpath/{R:1}" />
</rule>
You can do all these changes in the IIS Manager UI, but if you want to script them, look into the PowerShell IIS cmdlets.
I've created a virtual directory within our intranet web application in IIS 7.5. The virtual directory currently points to the following location:
\\fileserver\root\Departments
Whenever I enable directory browsing, it creates a web.config within the Departments folder.
My question is - Is there a way that I can set this up to change where this web.config file is generated? If possible, I'd like it to be generated in the parent directory aka. \\fileserver\root. Is this possible?
When using IIS Manager, and modifying a directory or virtual directory you can not specify where the new web.config is saved. It goes into that directory.
However, you can get away with not using web.config in any sub-directories and specify specific settings for various sub-directories. In the root web.config, use the location node such as:
<configuration>
<location path="Departments">
<system.webServer>
<defaultDocument>
<files>
<add value="blah.htm" />
</files>
</defaultDocument>
</system.webServer>
</location>
</configuration>
The path is the name of the sub-directory, anything inside the location node is just applied to that path.
If you want to use the GUI, you can use the Configuration Editor to change your settings and choose From:Root web.config at the top.
I have the following configuration:
Running Windows 7 Pro
Running local IIS 7.5 ( for web development purposes )
Edited hosts file to be able to use http://www.sitestepper.dev
Site build in subfolder of the inetpub/wwwroot/staplijst
Site can be viewed using http://www.sitestepper.dev/staplijst/whatever-page.htm
I have an http://www.sitestepper.dev/p.asp page I would like to call when an unknown page is requested. This technique works fine on the deployed version of this web site (deployed on an Windows 2003 server running IIS 6 - not sure about the 7 but it is the version deployed with Windows 2003 server).
I tried ( in the Edit Custom Error Dialog ) :
Execute a URL on this site: with value /staplijst/p.asp
and
Respond with a 302 redirect: with value http://www.sitestepper.dev/staplijst/p.asp
I tried this in the properties of the 'Default Web Site' , and I tried this at the staplijst level.
Even tried it with values without the /staplijst.
I restarted the default web site after each change. And even stopped/started the Web service.
But nothing seems to work, I keep getting the 'Server Error In Application "DEFAULT WEB SITE"' , HTTP Error 404.0 error.
What am I missing here - probably something obvious, but I don't see it ?
I just configured the following to reproduce your setup:
In the web.config file:
<configuration>
<system.webServer>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404"
prefixLanguageFilePath=""
path="/p.asp"
responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
In the root of the site I have a simple script called p.asp that does a Response.Write "Hello World".
If I browse to a page that doesn't exist p.asp is redirected to and I see "Hello World".
If I use the following in my web.config:
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404"
prefixLanguageFilePath=""
path="http://www.sitestepper.dev/p.asp"
responseMode="Redirect" />
</httpErrors>
This redirects as expected to p.asp and again I see "Hello World".
The only thing I can think that is wrong is that you say that p.asp lives in the root of the site: http://www.sitestepper.dev/p.asp but the ExecuteURL and Redirect response mode paths include /staplijst in the path.
To answer my own question: I needed to set the Error response to Custom error pages in the Edit feature settings... of the relevant site for this to work. It was set to 'Detailed errors for local requests and custom error pages for remote requests'.
I never had to do this in previous version of IIS, but maybe in those versions this was implied. Or maybe the host setting www.sitestepper.dev is causing the pages always to behave as local requests - anyway this has changed in IIS 7.5 I'm sure.
I searched for this solution without seeing the answer of 'Kev'. As a rule I tend not to edit config files directly if a solution can be found using the presented user interface panels.
I will accept his response as solution though.
.
We've inherited an application that uses the Intelligencia.UrlRewriter module. Our environment though is IIS7. We've already set our site to run in the classic asp.net application pool (which aparantly works for a lot of these kinds of problems). However we're still not seeing the URLs in our app be rewritten.
Has anyone run into this?
You need to define the config on the system.webServer element, like:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter"
type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</modules>
</system.webServer>
You can keep both config. What you probably have now is:
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</httpModules>
Check the section "Migrating ASP.NET Applications to IIS 7.0 Integrated mod" on http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/
ps. I have been using it with no trouble at all, as long as that config is in.
Update 1: Also check http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx, particularly "Approach 3: Using an HttpModule to Perform Extension-Less URL Rewriting with IIS7", since the config I added has the extension-less config.
Yes I had the exact same problem with Intelligencia.UrlRewriter module, running under Win Vista & IIS7, however switching to the classic asp.net app pool did fix the problem. Are you running the app in a new virtual directory? That can sometimes mess with the root path to the application which could make a difference to the rules in the web.config
I have spotted the same problem, after few tries I found out that changing asp mode to integrated pipeline helped.
Don't forget to add the following lines in the system.webServer section of your web.config file if you are using IIS7
<system.webServer>
<modules runAllManagedModulesForAllRequests=”true”>
<add name=”UrlRewriter” type=”Intelligencia.UrlRewriter.RewriterHttpModule” />
</modules>
<validation validateIntegratedModeConfiguration=”false” />
</system.webServer>
As in
http://frozengraphics.wordpress.com/2009/12/06/intelligencia-urlrewriter-and-iis7/