ASP.NET 2.0 introduced a new feature called Profiles where a web application can create users' profile - ASP.NET provides all of the plumbing work for you; all we have to do is define some settings in the web.config file and get/set properties on the Profile object in our code. Pretty simple.

I have been using the Profile feature for quite some time without any problems but yesterday I ran into a problem. No matter what I tried, I always got the Profile object null. After performing a little bit of research I came to know that the problem is with the Microsoft Office Sharepoint Server (MOSS) which is also installed on the development machine that I was working on!

Under the hood, ASP.NET Profile feature is implemented by a ProfileModule (an ASP.NET module) which gets run and initializes the Profile object during each request. When MOSS is installed on a machine, it clears some of the modules from the HTTP request processing pipeline and ProfileModule is one of those modules!

Hence adding the following line in my web application's config file did the trick for me.

<add name="Profile" type="System.Web.Profile.ProfileModule" />

Hope this tip would help others who might be facing the same problem.


 
Categories: ASP.NET

I was playing with AJAX samples by extending Javascript; I added couple of classes in a separate .JS file and included that in my aspx page.

The body section in the aspx page looked as follows:

Very simple page, right? Well, not so fast buddy; I got the following error when I ran the page.

I had no idea why this error occurred. I tried to isolate the problem by commenting/un-commenting different lines in the code, but no use and I kept getting the above error.

After trying for around two hours, I removed the <script> tag line which was including the AddClass.js file in my aspx page and re-typed that line again (I know it does not make sense but I ran out of ideas @ that time). My simple page now looked like the following:

I ran the page again and guess what, the page ran just fine and I saw the alert window.

Can you spot the difference between the two versions of the code shown above? In the original HTML, I had removed the closing </script> tag and had replaced > with /> in the script tag. <script type=”text/javascript” src=”Scripts/AddClass.js”/>

For some reason (which I don’t know yet), the browser did not like that. I re-typed that line and the Visual Studio automatically generated the end tag for me </script> and this time around the page ran fine!!!

The lesson learnt? Don’t be smarty pants all the time and let the IDE do the job for you; there was some reason that’s why Visual Studio generated the end tag as </script> instead of prefixing > with /.


 
Categories: Misc