How to clear browser cache on browser back button click in MVC4?

The problem with your approach is that you are setting it where it is already too late for MVC to apply it. The following three lines of your code should be put in the method that shows the view (consequently the page) that you do not want to show. Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1)); Response.Cache.SetNoStore(); If you want … Read more

client-side validation in custom validation attribute – mvc 4

Take a look at this: Using this tutorial I got my custom validation code running with no problem. The only difference I can spot in your code is the way you created the $.validator.unobtrusive.adapters.add function. The parameters are a little bit different but, maybe, the problem is just that you have not defined the … Read more

Enable rear camera with HTML5

Check out that shows how you can select sources using MediaStreamTrack.getSources(gotSources); You can then select the source and pass it in as optional into getUserMedia var constraints = { audio: { optional: [{sourceId: audioSource}] }, video: { optional: [{sourceId: videoSource}] } }; navigator.getUserMedia(constraints, successCallback, errorCallback); It is now fully available in Stable Chrome and … Read more

ViewModels or ViewBag?

Basically, Should everything be done through the viewmodel or is it Ok to also incorporate viewbag? Everything should be done inside a view model. That’s what a view model is. A class that you specifically define to meet the requirements of your view. Don’t mix ViewBags with ViewModels. It is no longer clear for the … Read more

The type initializer for ‘System.Data.Entity.Internal.AppConfig’ threw an exception

Do the following in the App.config file, Put the connectionStrings element is after the configSections element. Put the startup element after the connectionStrings element. <?xml version=”1.0″ encoding=”utf-8″?> <configuration> <configSections> <section name=”entityFramework” type=”System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089″ /> </configSections> <connectionStrings> <add name=”SchedulingContext” connectionString=”Data Source=XXX\SQL2008R2DEV;Initial Catalog=YYY;Persist Security Info=True;User ID=sa;Password=XXX” providerName=”System.Data.SqlClient”/> </connectionStrings> <startup> <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.5″ /> </startup> … Read more

Razor actionlink autogenerating ?length=7 in URL?

The ActionLink override you are using matches to the (string linkText, string actionName, Object routeValues, Object htmlAttributes) override. So your “Profile” value is being passed to the routeValues parameter. The behavior of this function with respect to this parameter is to take all public properties on it and add it to the list of route … Read more

ASP.NET Controller: An asynchronous module or handler completed while an asynchronous operation was still pending

In Async Void, ASP.Net, and Count of Outstanding Operations, Stephan Cleary explains the root of this error: Historically, ASP.NET has supported clean asynchronous operations since .NET 2.0 via the Event-based Asynchronous Pattern (EAP), in which asynchronous components notify the SynchronizationContext of their starting and completing. What is happening is that you’re firing DownloadAsync inside your … Read more

ASP.NET MVC get textbox input value

Simple ASP.NET MVC subscription form with email textbox would be implemented like that: Model The data from the form is mapped to this model public class SubscribeModel { [Required] public string Email { get; set; } } View View name should match controller method name. @model App.Models.SubscribeModel @using (Html.BeginForm(“Subscribe”, “Home”, FormMethod.Post)) { @Html.TextBoxFor(model => model.Email) … Read more