Whenever I tried opened the Entity Framework’s edmx file, Visual Studio 2008 would simply close. I tried to google, stack overflow. But couldn’t find the answer.
I noticed that when I double clicked on the edmx file, the status bar said “Initializing toolbox” just before closing of Visual Studio.
- Close all the open windows using the Window->Windows menu in Visual Studio
- Explicitly click on the “Toolbox” pane. From the menu you would choose View->Toolbox.
- Then double click on .edmx to open it. You should be able to open it successfully.
I still unsure whether .edmx opened because I closed all the windows or because I opened the Toolbox explicitly.
I couldn’t resist but write about the solution to the following problem as I have spent several hours on this.
If you are on .Net and you don’t want the user to type his username/password every time he comes to your website (even if he closes the browser and opens it again), you would typically use .Net’s Forms Authentication’s persistent cookie feature.
In your project you would use the following code:
FormsAuthentication.SetAuthCookie(userName, true /*createPersistentCookie*/);
<!--2880 minutes is 48 hours-->
<forms loginUrl="~/Account/SignIn" timeout="2880"/>
The above solution works well on all major desktop browsers but does not work on iPhone/iPad/iPod browsers like Safari & Chrome. I am not mentioning Opera because it does not behave the way modern browsers do.
I have spent several days looking for the solution.
The second suggestion from Scott Hanselman along with this suggestion from Brian Y worked only partially.
Scott suggests adding cookieless=”UseCookies” attribute as follows.
<authentication mode="Forms" >
<forms loginUrl="~/Account/SignIn" timeout="2880" cookieless="UseCookies" />
Brian suggests adding the following xml block to a .browser (browser definition file) file under App_Browsers folder in the project. Read the above Scott’s article to know about browser definition files.
<!--This is part of browser definition file remember. Not web.config. -->
<browser refID="Mozilla" >
<capability name="cookies" value="true" />
This worked partially. In the sense, if the user closed the browser and opened it again, it remembered the cookies and signed in without asking for the user credentials. But it ignored timeout=”2880″. So it worked only for 30 minutes.
And finally, few more days of hunting brought me to this article with suggests adding machineKey element to your web.config.
The above mentioned article suggests generating machineKey from this online tool and adding it to your web.config.
That’s it!! Combination of STEP 1, STEP 2 & STEP 3 above will bring you to a working solution.
I was extremely thrilled to see Safari & Chrome working past several hours. This was not an easy thing to crack. Thanks to all the people involved in providing different solution to this problem.
Thanks to the readers :)
If you get this error in your aspx page, you may end up spending several hours (like i did) before finding the actual cause. Actually, this error could cause due to multiple reasons. One of the reason is mentioned below:
A common scenario is when assigning an id to forms. ASP.Net automatically generates forms with ids form1, form2 etc. If your web form also contains the same id, then you might see this error.