Monday, January 17, 2011

How to Fix "PageHandlerFactory-Integrated" bad module "ManagedPipelineHandler in IIS7

After setting up a new Windows 7 computer with IIS 7.5 and Visual Studio 2010, I tried to start my ASP.NET 4.0 website using the Local IIS web server. However, right off the bat I was hit with the following IIS error message:

HTTP Error 500.21 - Internal Server Error
Handler 'PageHandlerFactory-Integrated' has a bad module 'ManagedPipelineHandler' in its module list.

Apparently, the reason I was recieving the Internal Server error message was that I had installed SQL Server 2008, after installing Visual Studio 2010, and because of this it corrupted the IIS Machine level configuration files ('If you install VS2010 and then install VS2008 and VS2008 SP1, the configuration files for ASP.NET in IIS only include about 1/2 of the correct .Net 4.0 configuration sections.' read more here).

To repair this problem I ran a full silent repair of the .NET Framework 4.0. Here's how on either a 32 bit or 64 bit computer:

1. Click Start -> All Programs -> Accessories -> Run
2. In the Open textbox paste in the following line (see list of all .NET Framework version install, repair and unistall command lines here):

For silent repair on 32 bit computer with .Net Framework version 4.0.30319 use:

%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart

For silent repair on 64 bit computer with .Net Framework version 4.0.30319 use:

%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart

3. Click OK to start the repair
4. After, the repair ran for a few minutes, I restarted IIS 7.5, and things began to work correctly!

Hopefully, that will work for you...

Sunday, January 9, 2011

Saturday, January 8, 2011

ASP.NET Cookies Expires property is not initialized

It appears that you cannot read is the cookie's expiration date and time - HttpCookie.Expires property. It turns out that when the browser sends cookie information to the server, the browser does not include the expiration information. You can read the Expires property, but it always returns a date-time value of zero.

Browser is responsible for managing cookies; the Expires property is an example of this. The primary purpose of the Expires property is to help the browser perform housekeeping on its store of cookies. From the server's perspective, the cookie either exists or it does not; the expiration is not a useful piece of information on the server side. Therefore, the browser does not provide this information when it sends the cookie. If you are concerned about the expiration date of a cookie, you must reset it.

At times you might want to modify a cookie, perhaps to change its value or to extend its expiration. (Remember that you cannot read a cookie's expiration date because the browser does not pass the expiration information to the server.)

You do not really directly change a cookie, of course. Although you can get a cookie from the Request.Cookies collection and manipulate it, the cookie itself still lives someplace on the user's hard disk. So modifying a cookie really consists of creating a new cookie with new values and then sending the cookie to the browser to overwrite the old version on the client.

The following example shows how you might change the value of a cookie that stores a count of the user's visits to the site:

Dim counter As Integer
If Request.Cookies("counter") Is Nothing Then
counter = 0
Else
counter = CInt(Request.Cookies("counter").Value)
End If
counter += 1
Response.Cookies("counter").Value = counter.ToString
Response.Cookies("counter").Expires = DateTime.Now.AddDays(1)

Source

Tuesday, April 6, 2010

Entity Framework Error 0019

I’ve got this error while refactoring a project that contains an Entity Data Model.  I’ve tried to google and find good solution.  Here it is:

image

Errors:

BAModel.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'BAEntities' is already defined.
BAModel.csdl(118,4) : error 0019: Each type name in a schema must be unique. Type name 'BAModel.Activity' was already defined.

One reason you might see this is if you have two models in a project that have the same schema. Maybe you decided to start your model over from scratch.

But in this scenario, that was not the case. It turned out that the problem was because I had changed the assembly name of the project that contained the model. The reference to the original assembly was still in the client application's BIN folder along with the new one.

image

Entity Framework was attempting to load the metadata files from both assemblies and detected the conflict.

Cleaning the project didn't fix the problem. The leftover assembly was still there.. I had to delete the dll and pdb file manually.

I first came across this problem and fixed it last week. But it happened again with another solution today and took me a while to remember the cause and the fix. The older I get, the more I need to rely on my blog for retaining that which my memory seems to be incapable of storing away.

Original solution

Thursday, April 1, 2010

Sitecore - CryptographicException file not found

I’ve got an issue with CryptographicException file not found in Sitecore. See details below

Server Error in '/' Application.

The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: The system cannot find the file specified.
]
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +7715070
System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSAParameters parameters) +258
System.Security.Cryptography.DSA.FromXmlString(String xmlString) +501
Sitecore.Nexus.Licensing.NexusLicenseApi.(String xml, Guid instance) +124
Sitecore.Nexus.Licensing.NexusLicenseApi.GetSnapShot(Guid instance) +683
Sitecore.SecurityModel.License.LicenseManager.GetSnapshotData(Guid instance) +47
Sitecore.SecurityModel.License.LicenseManager.UpdateSnapshot() +70
Sitecore.SecurityModel.License.LicenseManager.Initialize() +8
Sitecore.Nexus.Web.HttpModule.Application_Start() +76
Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +435
System.Web.HttpApplication.InitModulesCommon() +65
System.Web.HttpApplication.InitModules() +43
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +298
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289



Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927


After hours of trying to find the solution I’ve found out that this is IIS settings issue.   This issue was caused by MVC 2 installation, unfortunately it’s uninstall didn’t help.



To fix this:
1. go to IIS Manager
2. go to the application pool instance
3. click advanced settings
4. Under Process model, set Load User Profile to true
Hope this will help!
Eugene

Friday, March 26, 2010

How to Remove and Hide Blogger NavBar (Top Navigation Bar)

I find this Navigation bar on top of the blog useless for me and readers of the blog.

Unfortunately it’s not possible to hide this NavBar using blogger settings.   But you can do this manually editing Html of the page and adding needed CSS class there.  Here are the instructions:

  • Login to Blogger.
  • On the Blogger Dashboard, click on the Layout link of the blog.

    image

  • The Edit HTML page under Layout tab should be loaded. If not, go to the tab.
  • Search for the following line of code:

    </style>

    Then, add the following line of code before that line:

    #navbar-iframe{ display: none !important; }

    The Blogger Classic Template uses iframe to load the NavBar, and styles it with ID named navbar-iframe. The name actually also works for new Blogger Widget Template too.