ServiceStack httpHandlers not loading - asp.net-mvc-4

BaseLine: ServiceStack sample works for me in a stock MVC 4 app. I am using the variant, followed all the instructions in the readme, no problems.
Plugin Framework
I am building a plugin framework for MVC and servicestack.net is one of the plugins, that being all the assemblies are plugins which get loaded, using BuildManager.AddReferencedAssembly(assembly);
BuildManager.AddCompilationDependency(assembly.FullName);
All the ServiceStack dlls are found and successfully loaded from my personal shawdowFolder.
webconfig:
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory,ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory,ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
*NOTE: I am calling from Application_Start AppHost.Init(), and I can step it so ServiceStack is truly loaded and usable before the ASP.NET app goes into full swing.*
On first launch: /api/metadata results in:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /api/metadata
Stopping the debugger and simply relaunching, which deletes all assemblies from my personal shawdowFolder, copies them, loads them, references them, results in.
A working ServiceStack.net
StarterTemplate ASP.NET Host
The following operations are supported. For a formal definition, please review the Service XSD.
etc.
I suspect that this problable has to do with .NET's shadowfolder and appdomain, but perhaps it is something with ServiceStack. Where would I find logs to see if ServiceStacks httphanderfactory is having problems.

I Changed my config as follows :
SetConfig(new EndpointHostConfig
{ ServiceStackHandlerFactoryPath = "ss"}
and my config :
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v13.1, Version=13.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
<add name="FormsAuthenticationDisposition" type="ServiceStack.ServiceInterface.SuppressFormsAuthenticationRedirectModule, ServiceStack.ServiceInterface" />
</modules>
<handlers>
<add type="DevExpress.Web.ASPxUploadControl.ASPxUploadProgressHttpHandler, DevExpress.Web.v13.1, Version=13.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" name="ASPxUploadProgressHandler" preCondition="integratedMode" />
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v13.1, Version=13.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode" />
<add path="ss*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /></handlers>
<validation validateIntegratedModeConfiguration="false" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="30000000" />
</requestFiltering>
</security>
</system.webServer>
Now I have to type in the following to get to my servicestack area : http://localhost/ss/
My take on what is going wrong is that mvc/asp.net forms/ servicestack each needs one entry point to map its handler to an url route, servicestack is overriding the url route for "/" your MVC project hence no resources is found.
Thus in my application I used to seperate entries points:
*http://localhost/* .... is my normal entrypoint for webforms (in your case MVC4[stock])
http://localhost/ss .... is my servicesstack entrypoint
If you are using the MVC razor engine you won't run into this.

Related

system.identityModel not detected in web.config

I have an ASP.NET Core 1.0 project running. When I add the ClaimsPrinciplePermission attribute to my action methods I get the following error when navigating to any action method having that attribute.
An exception of type 'System.InvalidOperationException' occurred in
System.IdentityModel.Services.dll but was not handled in user code
Additional information: ID7024: Use of ClaimsPrincipalPermission
attribute has been attempted and possibly there is no
configuration section defined, see inner
exception for details. Also make sure a ClaimsAuthorizationManager
element is defined under the section.
This is the inner exception
ID7027: Could not load the identity configuration because no
configuration section was found.
This is my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
</federationConfiguration>
</system.identityModel.services>
<system.identityModel>
<identityConfiguration>
<claimsAuthorizationManager type="wApp.ClaimManager, wApp" />
</identityConfiguration>
</system.identityModel>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
As you can see, I have added all the required sections. The same code and configuration works well in my MVC 5 projects and also my Web Api project. Is there something different to be done in Asp.Net Core projects?
I have also added the required DLL references in the Core 1.0 MVC project as well duplicated the same configuration sections in the App.config file under the core 1.0 MVC project. Still getting the same error.
What am I missing?
ClaimsPrincipalPermission, and WIF/System.IdentityModel is not part of .NET Core at all. I'm surprised that even compiles.
From the comments it appears you're parsing a JWT, presumably with the JWT bearer token middleware.
So, all identities in ASP.NET Core are ClaimsIdentities. You can go for Simple claims based checks, or, more fully to code expressed policies which give a lot more flexibility.

How to use EmbeddedResourceVirtualPathPovider with IIS6

While developing a ASP.NET MVC4 web application with VS2010, using the Mvc.JQuery.Datatables Nuget,
I found that the EmbeddedResourceVirtualPathProvider NuGet that is referenced, worked beautifully
on my dev box, but failed miserably on my production box.
The production box is Windows 2003, with IIS6 and .NET 4.0 installed.
I searched many things on SO, and Googling, but after implementing the suggested workarounds,
it still fails:
Here's what I've done.
Implement AppInitialize as suggested by https://stackoverflow.com/a/5178993
Implemented Wildcard mapping for ASP.NET as suggested by http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
Implemented IgnoreRoute for static files as suggested by https://stackoverflow.com/a/3144841
but it still doesn't serve all of the files. I'm getting the embedded partial views, but not
the embedded css, js, and jpg files.
My web.config has an entry for the StaticFileHandler as follows:
<system.webServer>
<handlers>
<add path="*.css" verb="GET" name="Static css" type="System.Web.StaticFileHandler" />
<add path="*.js" verb="GET" name="Static js" type="System.Web.StaticFileHandler" />
<add path="*.jpg" verb="GET" name="Static jpg" type="System.Web.StaticFileHandler" />
<add path="*.gif" verb="GET" name="Static gif" type="System.Web.StaticFileHandler" />
</handlers>
</system.WebServer>
I appear to be missing something critical. Any Suggestions?
When using IIS6, all of the items listed in #1-3 are required, but additionally, you need to
recognize that IIS6 defines its handlers as httpHandlers in the system.web section,
whereas IIS7 calls them handlers and they are in the system.webServer section of the config file.
Therefore, you need to add the following to make it work in IIS6
<system.web>
....
<httpHandlers>
<add path="*.css" verb="GET" type="System.Web.StaticFileHandler" />
<add path="*.js" verb="GET" type="System.Web.StaticFileHandler" />
<add path="*.jpg" verb="GET" type="System.Web.StaticFileHandler" />
<add path="*.gif" verb="GET" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>

WebApi POST returns 404 on AppHarbor

I have a Asp.net WebAPI service that is hosted on AppHarbor which throws 404 error on POST requests. The MVC 4 controller's POST works perfectly though that is hosted in the same virtual dir.
The same WebApi works on localhost. I tried below options with no luck:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" >
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
I also tried setting up action based URL to check if that works, but no luck. I have even decorated the method with:
[AcceptVerbs("POST")]
Would there be anything that needs to be added to web.config or any authentication setting that I am missing.
Solved, it was because of a database problem. I over looked the default try..catch which was returning a
HttpStatusCode.NotFound (404)
instead of a 500 error code. Its up and running now.

Issue by adding mschart to the windows azure application with WCF service

I have a very strange issue. I am not able to run a windows azure application which has a WCF service and mschart in it.
Following are the steps to reproduce the error:
1) Create a new windowsazureapplication with a blank asp.net webrole
2) Now add a new WCfService
3) run to check it runs ok
4) now in one of the pages include mschart, and open the design of the page to make sure the webconfig is changed to use the mschart.
5) now try to run the project.
I am getting error message like this one:
Is this a problem with windows azure or am I doing somthing wrong?
FYI: This is not my first project on windows azure.
I think I have found the solution. You just need to add the following in your web.config inside system.webserver section:
<validation validateIntegratedModeConfiguration="false"/>
The final system.webserver looks like as below:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
After adding above, I did not see the problem at all.

HTTPHandler and svc

I've got an existing web application, that is installed on several machines. script clients and .net clients consume ".asmx" services through one machine, that routes all calls to other machines.
Client ----> |Website \ Virtual directory(HttpHandler)| ----> |Other server \ real .asmx|
I added a new .svc service that does the same functionality, and added a handler for it (directory's config):
<system.webServer>
<handlers>
<add name="MY_ASMX" verb="*" path="*.asmx" type="MY.AO.HttpProxy, Astea.AO.HttpProxy" resourceType="Unspecified" preCondition="integratedMode" />
<add name="MY_ASPX" verb="*" path="*.aspx" type="MY.AO.HttpProxy, Astea.AO.HttpProxy" resourceType="Unspecified" preCondition="integratedMode" />
<add name="MY_WSDL" verb="*" path="*.wsdl" type="MY.AO.HttpProxy, Astea.AO.HttpProxy" resourceType="Unspecified" preCondition="integratedMode" />
<add name="MY_SVC" verb="*" path="*.svc" type="MY.AO.HttpProxy, Astea.AO.HttpProxy" resourceType="Unspecified" preCondition="integratedMode" />
while asmx request are routed fine, my new .svc on the end server does not get called, and even the Httphandler is skipped. if i call the .svc directly on the other machine it works.
the error i get is:
WebHost failed to process a request.
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/26458746
Exception: System.Web.HttpException (0x80004005): The service '/Mysite/MyDirectory/settings.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/Mysite/MyDirectory/settings.svc' does not exist.
I already tried the folowing
add "buildProviders" to compilation section that removes .svc
Click on MimeTypes and enter “.svc” and “application/octet-stream” and save
add a handler :
nothing helps, http handler is not being called
p.s. Im working with AppPool .net 4.0 Integrated
.svc extensions are considered by default to be WCF services, and handlers/modules are already present for them. You can remove the existing handlers/modules by putting a element before your <add> element:
<remove name="svc-ISAPI-4.0_32bit" />
(or, if on win64:)
<remove name="svc-ISAPI-4.0_64bit" />
And, in the <modules> element:
<remove name="ServiceModel-4.0" />
I've found it. Adding:
<compilation debug="true" >
<buildProviders>
<remove extension=".svc"/>
</buildProviders>
</compilation>
caused an error, that got me to back off, at the first time:
"~/ServiceManagement.svc" demanded that the buildProvider for ".svc" will be on
"~/ServiceManagement.svc" is automatiacally created in the machine root config when you install MS AppFabric. Since I'm using that folder only for redirection, I don't need Appfabric there, so I removed it:
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<remove relativeAddress="~/ServiceManagement.svc"/>
</serviceActivations>
</serviceHostingEnvironment>