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">
                <h1>@ViewBag.Message</h1>
            </hgroup>
        </div>
    </section>
}
<h3 class="logo">A Title</h3>

<section id="loginForm">

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

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

Related posts

Recent Viewed