MVC4 web api not finding default document once deployed to webserver - c#

It works on localhost, but finds no default document on the webserver and complains about directory browsing being disabled. IIS7 on both, and both websites/app pools seem to be configured identically.
I've used the web api template in VS2012, which doesn't actually have any views. It only has an Index controller action in the HomeController.
Any ideas on why this could produce different behavior in the two environments?

So this addition to my web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<system.webServer>
fixed the problem. It seems to be required in the web.config for IIS7 on Windows 2008 Server, but not for IIS7 on Windows 7.

I had a user trying to publish a MVC4 application on IIS7 getting this error, it turned out it was because the user had set the application pool to use .Net 2 instead of .Net 4. Instead of getting an error indicating this though they received the above error, and it was only when we added the above module the real issue was uncovered.

Related

IIS express error500.24 web api

I migrate an dotnet framework web api application from vs 2010 to 2019.
I want to use IIS express for developpement mode debug.
My application is built with a api back in dotnet framework 4.5 using xml and not json and a front in dotnet winform.
sorry for the french messages.
thanks a lot for your suggest.
I've been stuck with this for a week
Vincent
I tried to change the web.config, the applicationhost.config (in the user iis express directory and the .VS\config directory.
add modules to IIS manager
Try removing this line from your web.config,
<identity impersonate="true"/>
Or,
as Described in here;
Your application's Web.config file specifies "identity
impersonate='true'".
In IIS 7 Integrated mode, client impersonation is not available in
some early request processing stages. Therefore, IIS will generate the
migration error message. If your ASP.NET Web application impersonates
client credentials (most common with intranet scenarios), you may want
to set the validateIntegratedModeConfiguration attribute to false.
Add this section to your config to overcome this issue,
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
thanks for your help
I have tried
validateIntegratedModeConfiguration="false"
and it worked only when I deleted the lines created in the applicationhost.config (but it's not a solution)
we finally found: the problem was that I modified the .csproj file; but the file used for the user configuration is the .csproj.user.
It is modified with the "property" tab of VS.
I had seen it in a post for an mvc web application, since we are using an api, I thought it was different because it is an api.....
My colleague showed me the options in the panel... and now it works!!!!
[]You have to modify in properties :
anonymous authentication : disable
windows authentication : enable
pipiline mode : classic
and that's all
Make sure all the following .NET modules are installed.
.NET SDK 6.0.100
.NET Runtime 6.0.0
.NET hosting 6.0.0
note that the above are the current versions the versions may differ.
also change the version of .config files by running as Administrator whether you open the .json on Notepad or your IDE.
make sure your Internet Information Services is up to date and have selected all features on IIS

Configure IIS 10 to run an MVC2 project running dot net 4.0 on a Windows Server. Currently only returns 500

I have almost no experience with MVC, so hoping someone can help me. I have already spent hours trying to configure IIS to run the applications.
The application runs fine in Visual Studio 2010. MVC2. I can configure the publish and publish output seems to work fine. I have configured IIS as I have many times, but more for a non-mvc .net application.
When uploading the application to the IIS directory I only receive 500 errors. The IIS log doesn't give me much info to work with.
For grins, I created a new MVC project and uploaded that started app up to IIS and received same IIS 500 error. This leads me to believe I've configured IIS incorrectly. The only thing I'm confident of is I've screwed up somewher.
Any and all help is very appreciated!
Screenshot for Trace:
click here to see screen shot of trace error.
Detailed trace Image
I assume the problem is you are hosting your web app in a folder by mistake. You didn't set in the root web.config of your web-application or website. It looks just like you are hosting your application in a virtual directory or a sub-folder.
As you can see its only <modules runAllManagedModulesForAllRequests="true" /> is only supported by root web.config or applicationhost.config.
Modules section is not listed in folder(Vdir) level's web.config.
So please ensure you are publishing your application to a site's root folder or a sub application.
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/

Deploying .NET Core 2.1 web application

I'm trying to deploy a .NET Core web application, and what happens is that I'm constantly getting a 500 server error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Regardless of what I put into the file system folder (I tried 3 different .NET Core web apps), there's always this error. I tried standard Visual Studio "Hello world" application - same thing. Logs are not created, this is the sample entry from the web.config file being used:
<aspNetCore processPath="dotnet" arguments=".\TestAppMin.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
I manually created logs/stdout folder and changed IIS app pool rights to it - read/write.
IIS pool is configured as "No managed code" and "Integrated" pipeline.
I tried debug and release mode - no avail. I changed exception handling to custom in Startup.cs - still 500 error.
Latest .NET Core SDK is installed on the server.
If I manually create default.htm file, it's being displayed properly.
Can someone please advise me what am I doing wrong? Is there a way to diagnose that?
Thank you!
Do you have enabled AspNetCore Module in IIS under Handler Mappings ? I got it on first position.

Installing an ASP.NET web API on IIS

I have built my first ASP.NET web API in MVC, when I debug the application from Visual Studio everything works perfectly.
Now I need to get these API's on my server...
I have tried copying the project files to the website root which usually works for normal MVC apps with views, and I have also built the project and copies the file full of DLL's and an exe to the IIS root.
Obviously, neither of these worked, anyone know what I am missing? Perhaps something I have to do with IIS?
I have now tried "publishing" the project and when I try to access the site this happens...
Thanks in advance!
Build the application then publish it. Copy the published files to a favorite IIS folder. Ensure you select the right version of ASP.NET in the server for your application in the application pool.
When you publish and get an error such as this it is often related to a configuration issue, or other non-supported .NET Runtime issue.
For best results, if you can get to the Event Viewer for the server a detailed error should appear there outlining the root cause of the issue.
If you don't have access to the server directly, updating the <system.webServer> section with the below should get you a detailed error.
<httpErrors errorMode="Detailed" />
Just please note DO NOT LEAVE THAT LINE IN PRODUCTION!

WebApi with Basic Authentication gives 500-internal error with IIS

I've created a WebApi with .Net.
On localhost (Visual Studio) all works well.
Also, when I publish it on a IIS 7 on a Windows Server 2008, it works well too.
Now I want to secure some methods.
I've created as
public class BasicAuthHttpModule : IHttpModule
and in the web.config I configured this as
<system.webServer>
<modules>
<add name="BasicAuthHttpModule" type="WebHostBasicAuth.Modules.BasicAuthHttpModule"/>
</modules>
</system.webServer>
The mehod I want to secure has [Authorize] above it.
On my localhost (debug in Visual Studio) it works well again.
With Postman I see that I can access the method with the specified username/password.
But when I put this on the IIS server, I get a 500 Internal Server Error:
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed
Must I configure IIS somewhere to achieve this, or has this an other cause?
Ensure that you have "Basic Authentication" installed for your IIS server.
Follow the steps as to how to manage which features are installed for IIS on your server by following the steps provided here: http://technet.microsoft.com/en-us/library/cc771209.aspx
Ensure that the feature "WWW-Service" -> "Security" -> "Basic Authentication" is selected.
Alternatively, ensure that the IIS user has the required rights to the folder/files of your site. Depending on what your site does, "Read and Execute" could be enough.
The user that is used for IIS7 is IIS_IUSRS.
Additional reading on the users of IIS can be found here: http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis
Already solved it!
I've discovered that there were two <modules> inside the <system.webServer> what caused the error

Categories

Resources