Statistics
Visits: 105082
Page Visits: 139158
Active visitors (monthly): 5364
Feed Count: 45
Most visited page: Adding value as a technical analyst
Archive : Dec 2010

MVC Version of LiteBlog is released

MVC Version of LiteBlog is released. This releases uses jQuery extensively. FckEditor is the richedit tool. In the previous version, AjaxControlToolkit was used extensively. ACT is suited for WebForms framework.

The MVC version is slightly faster, even without output caching. There is no ViewState (prevalent in the Webforms version).

Permalink | No Comments | Leave your comment
 

Forms Authentication in MVC

Authentication in MVC is controlled by the [Authorize] attribute. If this attribute is put in front of a controller action, the unauthenticated user will be redirected to the login form. Usually, the URL will be something like http://App/Login?ReturnUrl=/App/Page. After authentication, the user will be redirected back to the /App/Page Url.

If you are writing custom FormsAuthentication, this does not work. Usually, the user will be redirected to the default redirect page as specified in the web.config. Here is a forum post describing this situation: http://stackoverflow.com/questions/4246606/formsauthentication-getredirecturl-always-returns-the-default

As described in the post, a hidden form element can do the trick. But, it does not work, when the user retries a login (after wrong password). To make it work, ensure that ReturnUrl is present in the ViewData and passed along multiple invalid attempts:


<% if (ViewData["ReturnUrl"] != null)
 { %>
       <%= Html.Hidden("ReturnUrl",  ViewData["ReturnUrl"].ToString() )%>
 <% } %>

Permalink | No Comments | Leave your comment