Web server configuration error - c#

I uploaded my website on web server(www.somee.com) but there is an error which I am facing like many other new web developers face. I had done these things to get rid of this error. There is no error when I test my website on local host.
1) I have right clicked on my page named "WebHome.aspx" and make it start page.
2) After reading multiple solution I had tried most of them but still the problem is still there.
My web conf. file have following script
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<clear />
<add value="WebHome.aspx" />
</files>
</defaultDocument>
</system.webServer>
<authentication mode="Forms">
<forms loginUrl="WebHome.aspx" defaultUrl="WebHome.aspx" >
</forms>
</authentication>
Error:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Please help and Thanks in advance.

Related

Runtime Error after deploy asp.net webforms app in Microsoft Azure App service

I am trying to deploy in Azure WebApp service an ASP.NET Weforms.
The app runs fine locally, without any problem.
After build ends I got the error below error in web browser after i go to myapp.azurewebsites.net i
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
Here is source of Web.config file
<?xml version="1.0"?>
<configuration>
<configSections/>
<connectionStrings>
<add name="constr" providerName="System.Data.SqlClient" connectionString="server=telendar.database.windows.net; database=TrackerDB;uid=telendar;password=*****;"/>
</connectionStrings>
<location path="Admin">
<system.web>
<customErrors mode="On"/>
<authorization>
<allow roles="Administrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<system.web>
<compilation debug="true" targetFramework="4.5.1"/>
<sessionState timeout="60"/>
<authentication mode="Forms">
<forms defaultUrl="~/Default.aspx" loginUrl="~/AuthUser.aspx" slidingExpiration="true" timeout="60"/>
</authentication>
<authorization/>
<pages controlRenderingCompatibilityVersion="4.0" validateRequest="true">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>
You misunderstand the error message, it's telling you that your code crashed an unhandled exception and it's not allowed to show it ,it suggest you modifying the web.config to enable the details of the specific error message to be viewable on remote machines.
So what you need to do is recreate the error while you browse it on the server and then solve the problem.
However my suggestion is you could try to change your FrameWork maybe this will work for you.
If you still have other questions, please let me know.

HTTP Error 403.14 ASP configuration

I get this error while trying to initiate a project in ASP. I have already added
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
To the Web.config but I still get this error. Also, I have tried initiating the IIS Express by opening appcmd.exe but this did not fix it either. None of the solutions I have found worked for me so far.
Any ideas?.
Step 1. Open IIS
Step 2. Go to the WebSite you are facing issue with.
Step 3. Click on Default Document Button, you will find it on the right side tab in IIS.
Step 4. You can see a list of default documents, but your default page (aspx file) is not mentioned here and that is causing the issue.
Add your file here. (For example: Index.aspx)
You can also add the following entry into the web.config:
<system.webServer>
<defaultDocument>
<files>
<add value="Index.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
Hope it helps.

Configuration error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

I have developed a web application using c# and asp.net but when I am trying to publish and put it into the server using ftp then I am getting this following error:
Configuration Error
Description: An error occurred during the processing of a configuration
file required to service this request. Please review the specific error
details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This error
can be caused by a virtual directory not being configured as an application
in IIS.
Source File: \\fs8-n02\stor10wc2dfw1\555713\570520\www.gxxxxjjsxx.ssd\web\content\2way\armb
\web.config Line: 9
Here if I check on my Line 9 of the web config file then I get this:
<authentication mode="Forms">
And here is my complete web config file code:
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="2880"/>
</authentication>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages validateRequest="false">
<controls>
<add tagPrefix="ajaxtoolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolKit" />
</controls>
</pages>
<globalization culture="en-GB"/>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
I have checked whether I have multiple web config files but I could not find something like that. And also I have used this published folder into my IIS and I can browse the site from my localhost using IIS but still when ever I am trying to browse using the link:
I am getting the same error. Please help me on this. Thanks.
Here is my solution to the problem: Actually the path was not configured properly into the IIS as a virtual directory. So, that I had to create a proper virtual directory and then only I am able to access the site.

HTTP Error 401.2 - Unauthorized (for DefaultDocument)

I am getting a 401.2 error on the default document in VS2013 (and IIS). Here are the steps I'm taking:
In VS2013, right click choose "New Project"
Choose "ASP.NET Web Application", click OK
Choose "Empty" project, Check "Web Forms" at the bottom and click OK
Right click on the project and choose "Add | Web Form" - named
Default.aspx with "Authentication Succeeded" as the page content
Right click on the project and choose "Add | Web Form" - named
Login.aspx
Add a "Login" as the page content
Assign an "Authentication" event handler that sets "e.Authenticated
= true"
Update the web.config as listed below
Press F5
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="Login.aspx" />
</authentication>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="default.aspx" />
</files>
</defaultDocument>
<security>
<authorization>
<remove users="*"/>
<add accessType="Deny" users="?" />
<add accessType="Allow" users="*"/>
</authorization>
</security>
</system.webServer>
</configuration>
The behavior that I'm seeing is that http://localhost:12345/Default.aspx behaves correctly (always). In other words, when I first go to Default.aspx, it redirects me to the Login.aspx page. Once I've authenticated, I can see the Default.aspx page. If I logout and try to go to the Default.aspx page again it redirects me to login first.
However, when I got the / URL instead (no Default.aspx) I get a 401.2 error (even if I've authenticated 1st)?
The Default.aspx page is listed as a default document, and if I remove the "Deny" line from the Web.Config - then the default document behaves as expected. But when Deny ? is listed in the web config, suddenly the default document stops working and I have to go to /Default.aspx in order to avoid a 401.2 error.
Any suggests as to why this would behave like this?
I see no errors about any of this in the event log. I see the same behavior when using IISExpress (in VS by pressing F5) or with IIS when going to the public URL directly through a browser.
I hesitate to offer this as an answer as I don't understand exactly why it worked for me. However it is too long for a comment and it might help you.
I found that adding the following to the System.Webserver section solved this problem:
<modules>
<remove name="FormsAuthentication"/>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
</modules>
The key seems to be to remove the managedHandler Precondition from the FormsAuthentication module. As I understand it this is only supposed to optimize serving of static content. So I do not at this point know why it would have this effect. I stumbled on this trying to establish if FormsAuthentication module needed to be registered in the System.Webserver section.

Cannot not access (404) PDF file on production server (ASP.NET MVC)

I've added one folder "Manuals" to my ASP.NET MVC project. In this folder I have two pdf files.
In my view I have links like that:
XXXXXXX
As far I can see the links are generated property. On my development server:
XXXXXXX
On production server:
XXXXXXX
Checked on production server and the pdf's are present. But here is the problem - I can access pdf's on my local server, but on production server I get 404 error. What can cause that strange behaviour?
You can add MIME type in web.config. I think MIME type may be missing on IIS.
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".pdf" />
<mimeMap fileExtension=".pdf" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
IIS blocks unknown extensions by default, and throws a 404.3 error. To 'fix' this, you can add this to the web.config:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".pdf" mimeType="application/pdf" />
</staticContent>
</system.webServer>
More on this blog post

Categories