Today I have faced a problem when working with a previous developed ASP.NET MVC application. Just copy the database(.sdf) from previous version to new version. I have changed some validation and business logic. But when run the application it shows me the following error:
The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.
It was a running application after searching on community I have got the solution.
However, even if you manually update the database to follow the model, this exception will still occur. The reason is that EF does not check model schema completely: tables, columns, keys, indexes etc.
It calculates a hash of the model and compares with the hash of model…
Very recently I have worked on asp.net MVC application. Everything is working fine for MVC v1. But when move to MVC v2 I have gotten this error-
"This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet."
After making some r & d I have found the solution:
In MVC v2 they block Json for GET requests (as you can tell from the error) for security reasons.
If your JSON payload:
1.Contains sensitive non-public data
2.Returns an Array
3.Responds to a GET request
5.Browser making the request supports the __defineSetter__ method.
Then the data is vulnerable to a JSON hijacking. Typically, it's not *your* data but the data of the users of your website.
Note: If you use the master page in your application remember that you need to use 'Control.ClientID'. Because When the page is rendered in the browser, the content and master pages get merged into a single page. This means that the IDs for the controls get renamed. ASP.NET renames the IDs to prevent naming conflicts. Now to handle the renamed controls, ASP.NET provides the ‘Control.ClientID’ and ‘Control.UniqueID’ to get the renamed ID’s.
Use the following code at the Page load event to add items to the CheckBoxList programmatically: