Click here to Skip to main content
12,076,206 members (41,792 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

89.2K views
31 bookmarked
Posted

MVC4 Different Redirection Techniques (Razor)

, 25 Apr 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Different redirection techniques for MVC4

Introduction

This tip lists different redirection techniques for MVC4.

  1. HTML Tag
    <input type="button" value="Forgot Password" 
    onclick="window.location.href('@Url.Action("ForgotPassword","Account")')" />
       
  2. For posting, you could use a form:
    <form method="post" id="signin" action="@Url.Action("ForgotPassword", "Account")">
    <input type="button" value="Forgot Password" />
    </form>
       
  3. Using script:
    <script type="text/javascript">
        $(document).ready(function () {     
          $('#btnForgotPassword').click(function (e)      {
              location.href = '@Url.Content("~/Account/ForgotPassword/")';
          });
        });
    </script>
       
  4. If it is a link:
    @Html.ActionLink("some text", "actionName", "controllerName")
       
  5. For posting, use a form:
    @ using(Html.BeginForm("actionName", "controllerName")) { 
        <input type="submit" value="Some text" />
    }
       
  6. For Anchor Tag:
    <a href="http://www.codeproject.com/Controller/View" class="Button">Text</a>
       
  7. Using RenderAction:
    @{ Html.RenderAction("ActionName", "ControllerName", 
    new { FranchiseSetId = Model.FranchiseSetID }); }
       
  8. Also check this out…

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dhanraj_Patil
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionSample one is not working Pin
Hendrawan Harjanto20-Jan-14 0:09
memberHendrawan Harjanto20-Jan-14 0:09 
Generalnice collection Pin
the headlessnick23-Jun-13 20:21
memberthe headlessnick23-Jun-13 20:21 
QuestionNice details Pin
rahuljosh007200028-Apr-13 15:33
memberrahuljosh007200028-Apr-13 15:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.160208.1 | Last Updated 25 Apr 2013
Article Copyright 2013 by Dhanraj_Patil
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid