Enable directory browsing for ASP.Net Development Server - c#

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?

Related

How to launch web project with Visual Studio 2017

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.

Why getting 404 error for the api's on remote server

I have a ASP.Net WebApi project. I have deployed this on my local machine IIS.
On my local machine the api are runnning fine. Henceforth, I copied this set of file from my local machine to remote machine.
But while accessing the API's from remote machine, I am getting 404 Errors for all the apis.
I cross checked the IIS configuration on the machine. They are all same.
Local IIS
Remote IIS
http://localmachine/api/user/customer - On local running fine.
http://remotemachine/api/user/customer - on remote Http 404 error.
Any help/suggestion highly appreciated.
Thanks.
try to put in your webconfig in the module section...
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
<remove name="FormsAuthentication"/>
</modules>

"There was an unexpected server error" - IIS Version 7.5

I've developed a web application, I deployed this application on the server.
When I ran the application I am getting There was an unexpected server error, that is only error message it shows, no other details.
When I run this application using visual studio, it works just fine. I've tried with below <customErrors mode="On" />
Application pool has been kept in .net version 4.0
Asp.net has been registered with IIS.
Any ideas would help.
on server web.config try below config. you should see detailed error message.
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed"></httpErrors>
</system.webServer>
There was a network issue, which has been fixed, and it worked. Asp.net Impersonation has been "Enabled", Anonymous Authentication has been "Disabled". Enabled delegation [for kerberos] for the machine at the AD level. These made application work. There was no code issue at all as expected.

VirtualPathProvider won't see requests because * filetype handler not set on asp.net development server

I am using a VirtualPathProvider to serve some resources from .dll's (plugins). In IIS one can change the filetype filter for the ASP.NET ISAPI filter to '*'. How can I do the same for the ASP.NET development server that comes with Visual Studio?
Cheers in advance!
ASP.NET deployment server can process all request (similar to ISAPI configuration on IIS6) if you add this to your web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

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