Http Error 404:14 - Forbidden - asp.net

I've installed my web application already in IIS. But when we run it, it contains HTTP Error 403.14 - Forbidden. I've researched about the solutions.
Enabled Directory Browsing.
-But enabling directory browsing is not allowed.
Add Defalut Document
-I already have a default Document.
So now, I'm practically lost on how to solve this issue.

Have you already registered the framework for iis in the computer?
C:\windows\Microsoft.NET\Framework64\v4.0.30319> .\aspnet_regiis.exe -ir C:\windows\Microsoft.NET\Framework64\v4.0.30319> iisreset
run that in command prompt
Note: Path will of course change depending on your local drive

I've already solved this issue. There's just something wrong with my default document in my web.config. I used ~/Login.aspx instead of Login.aspx.
<defaultDocument enabled="true">
<files>
<clear />
<add value="Login.aspx" />
</files>
</defaultDocument>

Related

Enable directory browing for ASP.NET projects published from Visual Studio

I am trying to import an ASP.NET project which I know works and I am trying to build it on local. I imported the solution file in Visual Studio and went ahead and did a Clean and Build on it which went ok. Now I am trying to Publish the project and once I do that, I clicked the run button which says IIS Express and I see the following
HTTP Error 403.14 - Forbidden
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
If I was running this application out of IIS Manager, I know how to resolve this by clicking on the project, clicking Directory Browing and clicking Enable but I don't know how to fix this issue if I am running it from inside Visual Studio.
To resolve the issue you could try one of the below ways:
1)Set the below code in the web.config file:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
</system.webServer>
2)Set the default page for your project:
<system.webServer>
<defaultDocument>
<files>
<add value="pagename.aspx" />
</files>
</defaultDocument>
</system.webServer>
if you are using the MVC site then set default routs.

IIS error 500.19 error when reading web.config

I am running IIS under Windows Server 2016 and I'm trying to run an ASP.Net core 3.1 application but I can't get past this error:
500.19 error
(The language in the picture is Hungarian, but it contains no useful information whatsoever, just an example)
Here is my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Minibizz.Routing.Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
What am I missing?
P.S.: The web.config was created by Visual Studio 2019.
The reason behind the issue:
That error message goes on to say what exactly is bad about your configuration file, hence you should refer the “Config Error” and “Config Source” sections. This problem occurs because of the ApplicationHost.config file or the Web.config file contains a malformed or unsupported XML element.
if you are using url rewrite rule then install url rewrite Extention of iis. Enable ANCM logging, ie. set stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout\" (I think the path needs to end by a backslash), then run the web app and see if something gets logged into the stdout folder. Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site. Verify that the application pool has to write access to the logs directory.
Make sure you installed the .net bundle.check that you installed below iis feature:
You may also need to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
The web.config content seems to be correct. If you use a clean web.config copy, does the problem persist? If the issue can be solved by replacing web.config with clean configuration content, then the problem is exactly with this web.config. In this case, I suggest you remove parts of the web.config content to narrow down the issue. If the pages show correctly after you remove one section, then the problem is with that section. You need double-check what's wrong with the section and update the correct configuration.
If the problem remains even with clean web.config content, I suggest you access other pages in different folders in your site to see if the problem still exists.
you could refer this below link for how to publish asp.net core site in iis:
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio

Why is gzip compression not working on IIS 8.5?

I am unable to get gzip compression working on IIS 8.5 on a Server 2012 R2 machine. I have done some research and followed the instructions found in these posts:
How to enable GZIP compression in IIS 7.5
Compression in IIS 8.5 not successful, stating ALREADY_CONTENT_ENCODING
GZip Compression On IIS 7.5 is not working
gzip compression not working with IIS 8.5
Here is the relevant section of my config:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" staticCompressionIgnoreHitFrequency="true">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<!-- I have read that dynamic compression increases server CPU load.
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</dynamicTypes>
-->
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
Also, in IIS, I set compression to apply to anything larger than 256 bytes. And I have performed iisreset.
Nonetheless, I don't see the compression mentioned in my dev console in Chrome or IE and PageSpeed still tells me to compress stuff. What simple step have I missed?
It will be difficult to understand what is happening.Assuming that you have done all the IIS settings correct.
For checking if compression is working fine or not,How are you accessing the website. e.g. If you use an FQDN www.example.com ,please try and use localhost url. This will make sure your IIS settings are correct.
If localhost works fine and your Fully Qualified domain name does not work,then problem can be in the network.In order for compression to work,the browser needs to send request header accept-encoding:gzip, deflate . many at times your proxy or load balancer can trim this header and this header may not reach the IIS server.So IIS will never compresseven if all the settings are done right.
To verify what is happening for the request and why IIS did not compress the request,you can do the following.
make sure you have Failed Request tracing installed.
Configure your Failed Request Definition
Go to Failed Request tracing Modules
Click Add on the sidebar
Enable All Content and status as 200-999
And Finish the configuration.
Now reproduce the issue and you will get a traces captured in directory C:\inetpub\logs\FailedReqLogFiles\W3SVC .
Open the trace file(for each requests one file will be generated.Open the trace file in IE(make sure the request details matches the request you would like to verify) and go to the compact view
Search for Compression and also check the reason
As mentioned in answers to one of the questions the OP links to, be sure to check for any anti-virus software running on the server. In my case it was ESET. None of the IIS compression settings had an effect until the relevant ESET settings were disabled.
I'm leaving out details of the settings- I did what seemed like a pretty blanket disable and left it to IT to figure out which exact setting was most appropriate for compression to still work while retaining security.
I had a similar issue and was caused by ESET with some strange behavior.
It worked on some machines but not on the one with eset, it took me some time to realize.
What happened is that ESET caused chrome to downgrade http2 requests to http 1.1 and not compress them. It can be seen if you open network and enable 'protocol' column. After removing eset it worked even if I forced chrome to use http1.1 with '--disable-http2' flag
Anyway if it still not working I would try to (in addition to the other answers):
check if different clients behave the same (in my case only dev machine had the issue)
deploy a simple static site (event default one) and test
reinstall iis
check settings on iss server manager, configuration editor / system.webServer/httpCompression collection, change compression level

Redirect web.config IIS 8

I tried to make a redirect in web.config, but I get a 500 error. The version of IIS is 8.5, but before I was on version 6. What is wrong with this syntax ?
<location path="Test/test.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="http://domain/Test/IT/test.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
I get an this error message : Internal error - 500. I deleted the lines in web.config and everything works again.
I tried URL Rewrite feature, but I get an error.
"Cannot read configuration file due to insufficient permissions"
I am trying to fix with these instructions below, but the system asked me for user/password. I am as administrator, but those credentials didn't work.
Cannot read configuration file due to insufficient permissions
The HttpRedirectionModule is installed in the server. Also, RewriteModule
Did you install the HttpRedirect module? It is optional under IIS7+.
If that isn't it would help if you could post the detailed error message you get from hitting this locally if you can -- that will help narrow down the cause.
Finally, you might want to look into URL rewriting here, it is a new feature for IIS7+ that can handle simple url redirects like the above and much more.

IIS 7.5 error the requested resource can't be accessed

I'm trying to sort out my issue. i give all configuration issue but still getting this error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Error 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".
Config File \\?\C:\inetpub\wwwroot\WebSetup1\web.config
</modules>
116: <handlers>
117: <remove name="WebServiceHandlerFactory-Integrated" />
I also give access to Allow and in module also but still getting this error
using window 7 with IIS 7.5 + ASP.Net 3.5
any idea?
IIS 7.5 is a bear when it comes to user permissions. I would check that the defaultapppool or whatever your IIS user is for your app has permission to access the directory. Hope this helps.
Try to use in web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<!-- ... -->
</system.webServer>

Resources