I searched previous questions, first, but could not find anything that solved my issue. I have a Web App project that works fine locally, then fails with 500 after having been published. This is my first time using any of the Microsoft stack (C#, ASP.NET MVC, Azure), so bear with me.
Visual Studio 2015 Community
.NET 4.5 / ASP.NET 5 Web App project
StackExchange.Redis / Fleck / React.AspNET NuGet packages
I have added the following to web.config:
<system.web>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
...
<httpErrors errorMode="Detailed" />
<tracing>
<traceFailedRequests />
</tracing>
</system.webServer>
I also turned on detailed error messages under the web app's settings using the Server Explorer view in Visual Studio (right-click the app's name, click settings). I also attempted to remotely debug the web app, but received an "access is denied"("Remote debugging does not work in Express editions of Visual Studio" maybe?). So, I'll post the web.config from the Azure web app.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off"></customErrors>
</system.web>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpErrors errorMode="Detailed" />
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
<tracing>
<traceFailedRequests />
</tracing>
</system.webServer>
</configuration>
One or a combination of these changes mentioned above worked in providing a more useful error screen.
If someone can come along and post an answer as to which step(s) it may have been and why, etc. I'd be glad to accept it. I don't want to post an answer, as I honestly don't know which 'fixed' it.
Yes, the customErrors element belongs under system.web
The most common error people make when first deploying to Azure or any other server is to properly set connection strings for that environment, so I would start by checking those.
You mention ASP.NET 5 Web App project so this means you have a Startup.cs file, right?
Check in your project.json file if you have (if not add it) the Microsoft.AspNet.Diagnostics package.
Then add on the public void Configure handler:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
//other app.Uses
}
This is intended for local dev because it will show the detailed full error, you might want to later add it in an if:
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
Source: docs.asp.net
Related
I published an aps.net core 2.0 mvc app to a shared web hosting server that uses Plesk as control panel. The app works fine. However, I got the following error message when trying to access the web statistics:
This example.com page can’t be found
No webpage was found for the web address: https://example.com/plesk-stat/webstat/
HTTP ERROR 404
I contacted their support and got the answer "the .net core application settings aren't allowing the webstats to load. We recommend you consult with an experienced website developer to customize the web.config code accordingly for the website.", but they don't know how to configure the web.config file.
I really want to make the webstat to work. Any suggestion will be appreciated.
If URL Rewrite is blocking the access, try adding this string to the <conditions> section of the rule which is affecting webstat page:
<add input="{REQUEST_URI}" pattern="^/(plesk-stat/webstat)" negate="true" />
If that does nor help, configure failed request tracing to find which exact module is performing a redirect.
Along with changes in the web.config of the ASP.Net Core site itself to send the /plesk-stat/ url to IIS, a web.config must be added in the following directory:
C:\Inetpub\vhosts\{domain.tld}\.plesk\statistics\{domain.tld}\
(replace {domain.tld} with your domain), with the following contents:
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
</handlers>
</system.webServer>
</configuration>
This has to be done by the hosting provider on the server. Maybe you should contact the support of your hosting provider.
I'm building a web service against .NET 4.6.1 on ASP.NET Core. Locally it has been fine - I can debug no issues and everything works. Recently I took to getting it up online as an Azure Web App, which also works no problems now. The service loads and runs fine.
However I cannot remote debug it. When I do try to remote debug it, although it attaches no problems none of the break points fire and they turn hollow with the error No symbols have been loaded for this document.
I have tried and/or confirmed:
It is a debug build being pushed to a slot set to debug on VS 2015.
I've tried downgrading .NET to 4.6.
I've wiped out the Web App entirely and made a new one from scratch.
All extensions in VS 2015 are up to date.
In the VS Modules window, no modules or symbols have been loaded.
I have confirmed there is a PDB file present next to the app executable.
I have tried unchecking the "Just my code" checkbox in VS.
The Web App is configured for x64.
I have tried it on a completely different PC.
My web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="false" />
</system.webServer>
</configuration>
I am getting the following error when I try to launch my ASP.Net Core App using IIS Server v7.5 ... I published the website (File System option in Visual Studio) to a specific directory successfully. It launches fine from approot/web.cmd file. But when I try to hook it up to IIS Server and point it to the wwwroot folder, I get the following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x8007000d
Config Error
Config File \?\D:\WebDevelopment\UAT\creativeNamePROD\wwwroot\web.config
Requested URL http://10.2.177.226:59/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Failed Request Tracing Log Directory
Below are two different web.config files I tried any neither one worked. When I try to get into Configuration Editor within IIS, I get an unclear error as well. Any help would be greatly appreciated!!!
<configuration>
<system.web>
<httpRuntime maxQueryStringLength="64768" maxUrlLength="65536" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="64768" />
</requestFiltering>
</security>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
Web.config #2 -gets the same error
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
I was getting this error. I fixed this error by installing the .NET Core Windows Server Hosting bundle (vs the Runtime Bundle), as described in instructions like this one.
Install the .NET Core Hosting Bundle
Install the .NET Core Hosting Bundle on the hosting system. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse proxy between IIS and the Kestrel server. If the system doesn't have an Internet connection, obtain and install the Microsoft Visual C++ 2015 Redistributable before installing the .NET Core Hosting Bundle.
As #Patrick says you can download the bundle installables from this link.
After installing that Module, my app served (i.e. no 500 error).
I see #Jørgen made this comment on OP already, so he gets credit.
EDIT Please confirm you install the Hosting bundle vs the Runtime Bundle per comment by #MDave
Did you install the .NET Core Windows Server Hosting bundle? This is needed for IIS to work as a reverse proxy for the .net core libraries. You'll find the link in this article: learn.microsoft.com/en-us/aspnet/core/publishing/iis I had the same problem before installing this on my dev machine. – Jørgen Tvedt Mar 28 at 6:31
The only solution worked for me was to install 2 more items from Microsoft dot net core library:
https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.0.6-windows-x64-asp.net-core-runtime-installer
and
https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.0.6-windows-server-hosting-installer
This worked for me, delete file: project.lock.json and run dotnet restore, restart visual studio.
I was able to solve this same problem when running in Visual Studio Community 2017 v. 15.7.1.
Had to install the latest dotnet-sdk-2.1.300-rc1-008673-win-x64.
https://www.microsoft.com/net/download/dotnet-sdk-2.1.300-rc1-windows-x64-installer
I had this problem with one .NET 6.0 site, but not another, so I knew the hosting pack was installed and functioning correctly.
The issue turned out to be that the broken site had some elements pertaining the URL Rewrite module, but the module wasn't installed.
Problem solved by either removing those elements, or installing the URL Rewrite module.
I have a SUPER simple Web API. It is openly non-secure and simply provides free data. I'd like to move it from my personal server to shared hosting (e.g.: GoDaddy), but I'm having issues.
There are a lot of similar questions relating to 404 status when attempting to access Attribute Routing Web API services on shared hosting solutions. But none of them have worked for me. This is my SUPER Simple current setup:
Create a new .Net Framework 4.5 EMPTY C# Web Application named YourApplicationName
Ensure all checkboxes and packages are NOT Checked
Add a New "Global.asax" object
Replace the entire contents of the C# with the following:
using System.Web.Http;
namespace YourApplicationName
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start()
{
System.Web.Mvc.AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure((HttpConfiguration config) => { config.MapHttpAttributeRoutes(); });
}
}
public class TestController : System.Web.Http.ApiController
{
[System.Web.Http.Route("api/Test")]
public string Get()
{
return "Test Info";
}
}
}
Replace the Web.config file with the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</configuration>
Delete ALL References other than System and System.Web
PM> Install the following two packages:
Install-Package Microsoft.AspNet.Mvc
Install-Package Microsoft.AspNet.WebApi.WebHost
With that, I can run in Dev, publish to my personal IIS, run on my company's IIS Servers, or even publish to azure (http://suamereapi.azurewebsites.net/api/Test) and if I navigate to the route, I appropriately get back "Test Info".
But when I publish to my shared hosting, I receive a 404 status. Note that mvc controllers that return Views work just fine in the shared hosting, just not the ApiControllers.
Possible Issue 1 is that the IIS pipeline is not set up as Integrated on the hosted account. Of course I have checked that mine is set to Integrated.
Possible Issue 2: Moreso related to API's NOT using Attribute Routing, is that the Register Routes needs to come before the GlobalConfiguration. This is not applicable in a pure Attribute-Routing Web API setup.
Possible Issue 3: Some of the DLL's aren't in the shared hosting GAC, and also are not published from your local setup because they are not Copy Local. I have altered Copy-Local to multiple setups from none, to just what is required, to all references.
Possible Issue 4: Shared hosting messes with the configuration paths because of virtual directories for subdomains or what not. That is fixed by adding a rewrite to the Web.config as such:
rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
Possible Issue 5: Some say to fix the issue you need to add runAllManagedModulesForAllRequests="true" and work with the httpHandlers to remove and manually add extension handlers, and UrlRoutingModules.
I have done all combinations of these workarounds, but I can't imagine what the true issue is. Please let me know what I might be missing, I've spent days on this.
I have a REST C# web service that runs fine under IIS 6.0 and IIS 7.5 but for some reason I get a 404 when running under IIS 7.0.
The path to my dll is as follows: wwwroot\PHSendMessage\bin\PHSendMessage.dll
My web.config is the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpHandlers>
<add type="Service, PHSendMessage" verb="*" path="Request" />
</httpHandlers>
<httpRuntime requestValidationMode="2.0" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>
The class that inherits from IHttpHandler is named Service and this class contains the ProcessRequest function.
I am attempting to run the following url: http://localhost/PHSendMessage/Request?xml=hello
The above URL should call the get method and return the value from the "xml" parm to the screen, but I get a 404 error instead.
Everything I have read seems to point to the handler is not found, or not routing to my DLL correctly. I am not sure if the Web.config needs to have additional entries that are not required in IIS 7.5.
I have tried to follow numerous guides to adding the handler mapping but always the unhelpful 404 error. When following said guides I enter the Path and type similar to how I entered it in the web.config above and I may not be entering those correctly as I do not fully understand how these httpHandlers route to my dll.
Edit: I followed the following example: http://www.codeproject.com/Articles/112470/Developing-a-REST-Web-Service-using-C-A-walkthroug
I also followed their link to 404 errors. The source code from the above link is also results in the same 404 error.
Has anyone had similar issues?