3/05/2009

How to remove " This page contains both secure and nonsecure items " ? ASP.NET https Menu workaround

Somedays back , I had to deploy a ASP.Net application in a secure environment for my client . But when I deployed my application in https environment , it started displaying a message " This page contains both secure and non-secure items. Do you want to continue ? " . Being a developer , this message is ok to me . But clients who are generic users might get scared of this . So I was asked to remove this error message . So How to remove " This page contains both secure and non secure items . " ?

  • This message basically occurs when your application try to access a resource like image or some other file from a non secure server . So first you have to search for http in your code . Find all http links and replace them with https .
  • Now check whether all your images and files are hosted on the same secure server where your application has been hosted . If not move them to secure environment .
These two are the common reasons why this error occurs . In ASP.NET if you are using Menu control , it will also this error . So what is workaround for Menu in https ? If you are using the master page , paste the following piece of code in your masterpage code-behind .

protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterStartupScript(typeof(Page), "MenuHttpsWorkaround", Menu1.ClientID + "_Data.iframeUrl='Blank.htm';", true);
base.Render(writer);

}
Add a new blank HTML page to your application folder and replace blank.htm in the above code with that page . Aslo replace Menu1 with your Menu Item Id . Once you make the changes , publish the code and check it in secure environment . The error message would not display again .

For more ASP.NET Tips and tricks , subscribe to my blog or click here to get updates via email.

2 comments:

hi mate, long time no chat.. how r u? can we do exchange link for my other site?

Hogan scarpe are suitable for trail running. Americans have been adventurous all along is only endorsed by shoes that aim to safeguard lives of trail runners if Hogan scarpe uomo are anything to go by. Hogan scarpe donna is in the forefront of innovative technologies that eliminate fear element from trail runners' minds that otherwise are constantly haunted by the rough mountainous terrains, the forest route hogan donna run through without being able to concentrate on competition.

Post a Comment