How to launch web project with Visual Studio 2017 - c#

I tried to launch a C# web project from Visual Studio 2017 emulator and it doesn't work:
HTTP Error 403.14 - Forbidden
I'm using IIS and I'm not in wwwroot.
I already tried to activate in IIS but it's not what I want.
Any advice?

403.14 - Forbidden "The Web server is configured to not list the contents of this directory." is related to the directory your application is running in.
This problem might occur as you don't have neither Directory Browsing feature enabled nor you have configured a default document.
<system.webServer>
<defaultDocument>
<files>
<add value="your index file here" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
or
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
This page shows you the way how to configure one of the two features mentioned.

Related

Having trouble adding asp.net projects on Visual Studio 2017

I am building two separate webpages, contained within two separate projects on Visual Studio 2017, using asp.net framework. I am trying to add my first project into my current solution, to link with my new project. I have no issues adding the project, but when I try to run the imported project, it is giving me the following message:
HTTP Error 403.14 - Forbidden The Web server is configured to not list
the contents of this directory
Most likely causes:
A default document is not configured for the requested URL, and
directory browsing is not enabled on the server.
It also states in the title bar:
IIS 10.0 Detailed Error - 403.14 - Forbidden
I can run the first project and the new project by themselves and everything works fine, but when they are in the same solution, only the original project seems to work. Can anyone help me?
I think you just need to set some configurations in the web.config
<configuration>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>

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.

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

Enable directory browsing for ASP.Net Development Server

I want a directory listing/browsing available in my Asp.Net MVC application.
So I modified web.config:
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
and it works well under IIS or IIS Express.
But on VS Development Server it gives HTTP 404 The resource cannot be found.
Is there anything to make it work?

Forbidden to browse WCF svc file?

I am using VS2010 + C# + .Net 4.0 + IIS 7.5 + Windows 7. When I open an svc file (in IIS manager, right click the svc file and select browse) for a WCF project in IIS, there is an error like this, any ideas what is wrong?
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.svc' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Here is the content of the web.config file I am using, is it correct?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svc" />
</staticContent>
<handlers>
<remove name="svc-ISAPI-2.0" />
<remove name="svc-Integrated" />
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
</system.webServer>
</configuration>
You may have to launch the command servicemodelreg –ia in Visual Studio command prompt.
If it's not working, check if you have "WCF http activation" feature installed (Add/Remove Programs - Turn Windows Features On or Off - Microsoft .Net 3.5.1).
UPDATE 1: Probably your application is hosted under .NET 2.0 App Pool. Go to IIS Manager and check for Basic Settings… link. Click Select button and you will see which option are you using. Change it to use .NET 4.0
UPDATE 2: Your web.config file seems incomplete. I suggest you to configure your service using WCF Configuration Editor tool. Launch it (make sure you are using .NET 4 version of the tool) and open your web.config file. Create service configuration and service endpoint configuration, then save it.
Its likely the mime types not setup correctly on IIS, try using the aspnet_regiis tool. Failing that, I'd recommend adding a mimetype to your virtual directory in iis for .svc files to be handled by the .NET runtime.

Categories