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?
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 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
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've tried to rewrite a URL of a .aspx page, but i find all times this error :
error 500.23 : An ASP.NET httpHandlers configuration does not apply in Managed Pipeline mode.
premise: I'm using Visual Studio 2012 and c#
web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="viaggi/*.aspx" type="mioRewrite, mioRewrite"/>
</httpHandlers>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="strConn" value="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\db_viaggi.mdf;Integrated Security=True" />
</appSettings>
</configuration>
class mioRewrite inherited by the class IHttpHandlerFactory
public class mioRewrite : IHttpHandlerFactory
{
public IHttpHandler GetHandler(HttpContext context, string requestType, string URL, string pathTranslated)
{
classe HttpContext
context.Items["fileName"] = Path.GetFileNameWithoutExtension(URL).ToLower();
return PageParser.GetCompiledPageInstance(URL, context.Server.MapPath("viaggi.aspx"), context);
}
public void ReleaseHandler(IHttpHandler handler) { }
}
I've used this method because some samples talk about it.
What I've to do to solve this error, and for creating a URL rewrite method?
The error is giving you your clue. Rather than running IIS in integrated mode, it needs to be run in classic mode.
Interestingly enough, this is an issue that my company had opened a ticket with Microsoft for. The IIS engineers confirmed that it appeared to be a bug and were unable to provide a resolution. IF using extensionless routes AND rewrite rules, we had to leave IIS in classic mode.
If running in IISExpress and not full IIS, you can still change to Classic Mode for your application with the following steps:
Click on the web project in the solution explorer
Press F4 to get the properties page to show up. You do not want the full, multi-tab properties page but rather the small properties window.
Find the 'Managed Pipeline Mode' dropdown and change this to 'Classic'
I'm trying to deploy a mostly empty asp.net webforms app (with a custom httpmodule specified in web.config) to Azure and getting the following error:
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: An error occurred loading a configuration file:
Access to the path
'D:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\xqhbvcov.tmp' is
denied.
Source Error:
[No relevant source lines]
Source File:
D:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
Line: 0
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.276
Any ideas? I'm not sure what other information may be pertinent so if I'm missing something vital please ask and I'll supply it.
Entire web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--<httpModules>
<add name="AbcdModule" type="org.abcd.abcdHttpModule"/>
</httpModules>-->
</system.web>
<system.webServer>
<modules>
<add name="AbcdModule" type="org.abcd.abcdHttpModule"/>
</modules>
</system.webServer>
</configuration>
I had discussion with Windows Azure Websites team and found that custom HTTP Modules are supported with Windows Azure Websites so they should work and problem could occur depend on how complex the registration is.
For the sake of testing, I use the link below to create a custom HTTP Module and tested it in Azure Website which worked without any issue:
http://msdn.microsoft.com/en-us/library/ms227673%28v=VS.100%29.aspx
If you can provide more info about your custom HTTP Module (which seems to be part of org.abcd namspace and anything else) we sure can help. Alternatively you can submit the request at Azure Websites Forum, someone can help you directly.