Having trouble adding asp.net projects on Visual Studio 2017 - c#

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>

Related

AllowAnonymous Attribute in ASP.NET MVC5

I'm working on an older ASP.NET project and debugging in IISExpress and have implemented an API controller method that should require no authentication/anonymous (the project is set to Windows Authentications I believe).
Within APIController, I have added the following attribute above the method:
[System.Web.Mvc.AllowAnonymous]
Within the web.config file I have added the following with a correct location:
<location path="api/GreenTime">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
However, when visiting the API Controller/Method, the browser prompts to credentials and returns a 401.2 error if domain credentials are supplied.
I found the issue. AnonymousAuthentication was set to false in the VS Project settings. You have to click on the project in the solution explorer and press F4 to find the settings.

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.

Windows Authentication .Net Core 2.0 Show Username Without Security Prompt

I created a brand new Asp.Net Core 2.0 web mvc application with windows authentication enabled.
If I immediately hit play it prompts me for user credentials which is not what I want. If I hit cancel it then redirects me to a 401.2 unauthorized error screen with the following error:
"You are not authorized to view this page due to invalid
authentication headers."
When I then stop the application and enable anonymous authentication on the project and hit play again, it runs the application successfully but will not display my username. #User.Identity.Name returns empty string.
How do I get around the security prompt while still being able to display my username?
In the .NET Framework, I would use this in the web.config file along with anonymous authentication = true and it would work the way I want:
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
I am using Visual Studio 15.4.1.
I think that the <authentication> tag is related to ASP.NET, and not IIS. In ASP.NET Core, the System.Web pipeline doesn't run.
I've had success in implementing Windows authentication with ASP.NET Core by using the following configuration in the web.config
<configuration>
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</configuration>
The <system.webServer> section is the one getting modified when you change the authentication settings through IIS Manager.
Edit after Ben's first comment
Sorry, I had misread part of your initial message, and thought that you were trying to deploy your application in IIS.
It looks like Windows Authentication is set up correctly since you get prompted for credentials. What I don't understand is why you get prompted. I'm using IE11, Edge and Chrome, and they all know how to send Windows credentials without prompting me.
What browser are you using when doing your test? Could you try with the ones I listed above?

"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.

Error accesing ASP.net MVC Application under Umbraco Application IIS

I am using Umbraco 7.2.4 Application in our Project, I have another application which should run under Umbraco Site. Like as Below:
Umbraco Root URL: SampleUmbraco.com
Child Application : SampleUmbraco.com/MyApplication
I create a sub application under the Root Umbraco Application in IIS, and I added my Application URL to “umbracoReservedPaths”: “~/myApplication”.
But still my child application “SampleUmbraco.com/MyApplication” is still not running.
Do I need to change any other configuration settings?
Can any one one Help me in this issue?
Is myApplication not running at all, or does it give an error? We have previously had to add a location element around system.web and system.webServer in the web.config to make "sub" applications work. Like this:
<location path="." inheritInChildApplications="false">
<system.web>
..
</system.web>
<system.webServer>
..
</system.webServer>
</location>
But our sub applications were up, they "just" threw different YSOD errors.

Categories