Tag Archives: ASP.NET

Tip: Clearing QueryString when using RadControls and ASP.NET WebForms

I had to google myself silly and the page I ended up finding was so hard to find I couldn’t actually find it again to link to it properly. The below code is not my idea, so if you feel wronged, submit your link and I shall attribute properly.

The problem is: I want to be able to navigate, or find my way back if you will, to a certain MultiPage and TabStrip that is nested inside a Telerik RadGrid. As it is a view and not a state change, I would like the querystring to handle this. However, to be nice, or obnoxious, depending on how you see it, Telerik will resubmit the same querystring when you navigate the tabs yourself, which will make it so that after changing tabs via querystring once, you cannot navigate to a different page by clicking anymore.

Anyway: People on the Internet, especially Telerik forums tell you to do Request.QueryString.Clear(), but that just doesn’t work because it is a readonly Collection and although it compiles, you will get a runtime error. So: What to do?

The post that I found simply used violence and Reflection to force the collection into being Read/Write, and then when Telerik reads from Request.Querystring to needlessly resubmit the exact previous query, it actually, accidentally, posts the correct, cleaned querystring. This enables my expected scenario where you by using GET can change tabs in a TabStrip/MultiPage.

        private void ClearQueryStringParam(string paramName)
        { Continue reading Tip: Clearing QueryString when using RadControls and ASP.NET WebForms 

Castle Windsor + NHibernate + MVC revisited

I have noticed some people come to this blog for reference on using Castle Windsor together with NHibernate and ASP.NET MVC, so I have to mention a few things that have happened since I last posted about it several years ago. First of all ,there is an excellent sample application that shows the simplicity with which you can hook these things up.

The sample shows you how to register Castle in an MVC application. how to add logging and how to hook up NHibernate 3.2 . This is far, far easier than what I described years ago thanks to improvements in all involved frameworks, really.

The important things to remember are:

  1. Use NuGet to install your libs
  2. Use MVC:s way of installing an IoC container (as demonstrated)
  3. Use logging, you might as well.
  4. Hook up the NHibernate Session Factory as a singleton and hook up ISession to request a new transient session from your singleton SessionFactory. There you go, the magic is taken care of.
  5. This is not mentioned in the demo, but if you are going building production code consider buying a subscription for NHProf if you don’t have one already. It wlll tell you where you mess up and need to do better.
  6. As above, look into hooking up Glimpse, see Scott Hanselman’s blog about it below.

Castle Windsor + NHibernate + log4net + ASP.NET MVC Sample

Windsor tutorial ASP.NET MVC 3-application To-be-Seen

Scott Hanselman on Glimpse:
If you’re not using Glimpse…