ASP.NET MVC3 HttpApplication doesn't fire events like BeginRequest, EndRequest, PostAcquireRequestState etc. So it works fine but it doesn't fire events! I have tried to reinstall asp.net via aspnet_regiis - but there was no luck. Also i have tried to put events to Application_Start the same result.
I published web site via Web Deploy.
The interesting thing is - i have created new MVC project for testing purposes, deploy it and it works - HttpApplication events work perfectly.
Configuration:
WINDOWS 2008R2, IIS 7.5, ASP.NET MVC 3, all updates were installed.
Any help will be appreciated. Thanks in advance!
Example of subscribtion to HttpApplication events:
public MvcApplication()
{
EndRequest += MvcApplication_EndRequest;
PostAcquireRequestState += MvcApplication_PostAcquireRequestState;
PostAuthenticateRequest += MvcApplication_PostAuthenticateRequest;
}
There is a pretty good article on this: http://forums.asp.net/p/1306960/2572147.aspx#2572147
It should be a better solution than turning on managing of all requests by managed handlers. The latter is not very interesting for performance.
As you saw from my comments i found a solution, but it's not complete solution, because it should work with runAllManagedModulesForAllRequests="false", probably because i don't want, that static content will be involved in integrated pipeline - it's performance cost effective!
So i found real solution thanks to Kev: Prevent IIS from serving static files through ASP.NET pipeline
Related
I recently upgraded to ABP 4.10.1 and every method in AppServices were now suffixed by Async, I think it's great news for us backend developers but it's not so great for the frontend developers / external users of the API -> the Swagger documentation feels less easy to read :
every Create became CreateAsync
every Update became UpdateAsync
...
I think the "Async" is really not needed. Is there a way to act on the CreateControllersForAppServices to tell it to remove any trailing Async when creating the Web API methods while keeping the AppService naming for backend developers?
Thanks in advance.
One way is to use ActionName attribute if you are willing to add this to every method.
[ActionName("Create")]
public string CreateAsync()
{
return "Hello from Create Method";
}
I'm building a profile page with update form. After submitting the form with new data and several page refreshes I see sometime new and sometimes old data. It depends on thread handling current request. One thread contains new data and another one old. NHibernate is configured using ThreadStaticSessionContext and NoCacheProvider. In Autofac UserStore, OwinContext.Authentication and UserManager are configured as InstancePerRequest.
I tried to change ThreadStaticSessionContext to CallSessionContext and it started working normally. So the question is: why it works(ThreadStaticSessionContext is preferable for multithread apps) and what negative effects can it bring?
Thanks!
ThreadStaticSessionContext is for long running processes such as windows services or windows apps. For web applications you want to be implementing Session Per Request. This is what the WebSessionContext is for.
I actually don't use any of the contexts and just wire it up myself. See my answer here for an example.
I'm looking to leverage the QueueBackgroundWorkItem feature in available in .NET 4.5.2+ on our ASP.NET Web API application, however, I consistently am getting "Invalid Operation" exceptions when attempting to put something into the queue. I believe this may be related to the fact that our app is self-hosted using OWIN and the queueing of the work item is an IIS only feature? If this is true, just wanted to see if there would be any suggestions at all in regards to queueing background work from an owin-self hosted API.
HostingEnvironment.QueueBackgroundWorkItem() is part of System.Web and as a result, it will only work in the classic ASP.NET pipeline. It won't work in self-hosted OWIN pipeline.
Hangfire is your only option to run long background tasks
I had this issue in a test environment answered here.
In the end, I used Hangfire and its fire and forget code
//Fire-and-forget tasks
// Static methods are for demo purposes
BackgroundJob.Enqueue(
() => Console.WriteLine("Simple!"));
Have anybody used EFProf (http://www.hibernatingrhinos.com/products/EFProf) with IdeaBlade?
I have problems with start working with that. There is the connection between apps (because I see name of the app in toolbar) but no queries are presented.
Any ideas?
In an n-tier or Silverlight application make sure that you call the EFProf initialization on the server. The application_start method in the global.asax is a good place for this.
I am looking for a way to batch requests to the server. I found a post by Brad Wilson outlining how to make a batch handler using a message hanlder http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html#more but I wasn't able to get this working.
first I had compile errors because webapi did not understand "route-specific endpoint handler" like Brad's example used. there were also problems with the media type and/or formatter (can't remember which). My next attempt was to make a batch controller. so instead of a batch handler I had a batch controller. I almost has this working except when I used the MessageHandlerInvoker to call the individual commands I got exceptions about the additional handlers I have regsstered (1 for logging request/response and another to mimic user authentication).
At that point I stopped and reverted back to individual requests, not ideal, but it works.
My environment:
.net 4.0
VS 2010
mvc 4 front end (calls webapi)
webapi as a service tier
Has anyone else had any success with batched messages and webapi?
To be able to use per-route handlers you need ASP.NET Web API RTM which was only released yesterday (at the time when Brad wrote the article, it would only work with nightly MyGet feed builds or against Codeplex source).
You can get entire MVC4 RTM here or simply off Nuget.