I'm new to MVC and trying to write a code that would check for Window user permissions before the Login page is displayed and in showing and logging permission errors on a page.

Is that possible to do it through Global file?

Is there is a way to store an error message and display it instead of the login form?

This is my login page:

@model WebSecurityAdmin.Models.LoginModel

@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
<h3 class="logo">A Title</h3>

<section id="loginForm">

@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {

        <legend>Please login</legend>
                @Html.LabelFor(m => m.UserName)
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
                @Html.LabelFor(m => m.Password)
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
        <input type="submit" value="Log in" />

Related posts

Recent Viewed