Archive

Posts Tagged ‘ASP .NET’

.NET C#: Recycle current Application Pool programmatically (for IIS 6+)

February 12th, 2008 leandrodg 6 comments 4,721 views

I’ve been working on how to recycle the current application pool for my ASP .NET application.

There are 3 steps for doing this:

  1. Verify if application is running on IIS that supports application pools (if not, there’s nothing to recycle).
  2. Get application pool name (obtained from the DirectoryServices entry corresponding to our virtual directory).
  3. Invoke Recycle method in the DirectoryServices entry corresponding to the application pool.

Read more…

Cassini & SerializationException: Type is not resolved for member…

December 18th, 2007 leandrodg 4 comments 2,873 views

I’m working on an architecture project now, and I needed to create an HttpModule which would measure the request time for pages.

So I needed to save information (the time and some other data) in the Begin_Request event and then read it in the End_Request event. I could have used Request.Context, but part of the idea of the project is this information in the current thread because it can be used both in Winforms and in Webforms.
This information is saved in the current thread using a class that implements ILogicalThreadAffinative. When I saved my information in the current thread (using CallContext.SetData()), suddenly an exception (not debuggeable) came up, which said:

System.Runtime.Serialization.SerializationException: Type is not resolved for member 'xxx'.
   at Microsoft.VisualStudio.WebHost.Server.GetProcessToken()
   at Microsoft.VisualStudio.WebHost.Host.GetProcessToken()
   at Microsoft.VisualStudio.WebHost.Request.GetUserToken()
   at Microsoft.VisualStudio.WebHost.Request.GetServerVariable(String name)
   at System.Web.Security.WindowsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Read more…

Categories: Development Tags: , , , ,

Performance Counter InstanceName issue

November 21st, 2007 leandrodg No comments 936 views

I was creating a performance counter collection to register the processing time for ASP.NET requests, and I decided the best way to name instances was to use Request.Url.Authority + Request.Url.PathAndQuery. This counters would allow me to check average response time, total requests and requests per second, for each Request.Url.Authority + Request.Url.PathAndQuery.

I built the counters and I decided to create a _total instance too, to sum up all the requests being made to the server.

Rarely, the _total instance worked like a charm when looking at it in PerfMon, but the other instances (for example, localhost/Test.aspx?query=x) didn’t show a value, they all showed “—” in the report view of PerfMon. I had no idea what the problem was, but I saw that the failing counters showed up in the counters list with localhost in the Parent column and Test.aspx?query=x in the Instance column.

Read more…

Determine current execution context (ASP.NET or Winforms)

October 5th, 2007 leandrodg 2 comments 2,156 views

I’ve searched over the internet for this and couldn’t find anything.

A method I’m working on should have a different behavior when called in a Web Application (Webforms) and a Windows Application (Winforms).

Read more…