ASP.NET MVC 4 - Redirect to the same page after controller ends

Ralph

From a page I have the following:

@using (Html.BeginForm("AddEntry", "Configure", FormMethod.Get, new { returnUrl = this.Request.RawUrl }))
{
    @Html.TextBox("IP")
    @Html.Hidden("TypeId", 1)
    <input type="submit" value="@Resource.ButtonTitleAddComponent" />
}

so controller is called correctly:

public ActionResult AddEntry(string ip, int TypeId, string returnUrl)
{
    // Do some stuff

    return Redirect(returnUrl);
}

My problem is that returnUrl gets null and it does not redirect to the same page that called the controller. Ideas?

Using: ASP.NET MVC 4 Razor

Felipe Oriani

You could use a Request.QueryString method to get some values from URL, for sample:

@using (Html.BeginForm("AddEntry", "Configure", FormMethod.Get, null))
{
    @Html.TextBox("ip")
    @Html.Hidden("TypeId", 1)
    @Html.Hidden("returnUrl", this.Request.RawUrl)
    <input type="submit" value="@Resource.ButtonTitleAddComponent" />
}

And in your controller, receive it as a parameter string returnUrl.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Asp.net mvc Redirect to same page after login

From Dev

Asp.net mvc Redirect to same page after login

From Dev

Asp.Net MVC - redirect to same page without passing parameter

From Dev

Asp.Net MVC - redirect to same page without passing parameter

From Dev

ASP.NET MVC Redirect to target page or redirect to previous page after login

From Dev

ASP.NET MVC Redirect to target page or redirect to previous page after login

From Dev

How to redirect in same tab in after form submisson inspring mvc controller

From Dev

asp.net MVC 4 redirect to details after creating a new item in database?

From Dev

ASP.NET MVC post to controller action from same controller

From Dev

How to publish two asp.net mvc 4 applications with same controller names as single site on IIS

From Dev

Asp.NET MVC : redirect to another controller with POST Action

From Dev

redirect in asp.net mvc 2 controller initialize routine

From Dev

MVC 4 Redirect when session ends

From Dev

Redirect after confirmation in ASP.NET WEP API controller

From Dev

ASP.NET MVC 5 Wrong Redirect Login Page

From Dev

Redirect to page OnActionExecuting method ASP.NET Core 5 MVC

From Dev

ASP.NET MVC 3 Redirect Requests to Root Page

From Dev

ASP.NET MVC 3 Redirect Requests to Root Page

From Dev

Redirect Page based on dropdown information in ASp.NET mvc

From Dev

ASP.NET MVC SqlException does not redirect to error page

From Dev

Redirecting to the same page with different redirect parameters in ASP.NET

From Dev

Redirect to specific page after session expires (MVC4)

From Dev

Refresh part of page after successful user sign in (ASP.NET MVC4)

From Dev

Redirect user after authentication with OpenIdConnect in ASP.Net MVC

From Dev

Data is not displayed after Page Redirect ASP.NET C#

From Dev

Return different views same controller in ASP.NET MVC

From Dev

after submit redirect to the same page

From Dev

Parsing json in ASP.NET MVC4 controller

From Dev

ASP.NET - MVC 4 using a variable from a controller to a view

Related Related

  1. 1

    Asp.net mvc Redirect to same page after login

  2. 2

    Asp.net mvc Redirect to same page after login

  3. 3

    Asp.Net MVC - redirect to same page without passing parameter

  4. 4

    Asp.Net MVC - redirect to same page without passing parameter

  5. 5

    ASP.NET MVC Redirect to target page or redirect to previous page after login

  6. 6

    ASP.NET MVC Redirect to target page or redirect to previous page after login

  7. 7

    How to redirect in same tab in after form submisson inspring mvc controller

  8. 8

    asp.net MVC 4 redirect to details after creating a new item in database?

  9. 9

    ASP.NET MVC post to controller action from same controller

  10. 10

    How to publish two asp.net mvc 4 applications with same controller names as single site on IIS

  11. 11

    Asp.NET MVC : redirect to another controller with POST Action

  12. 12

    redirect in asp.net mvc 2 controller initialize routine

  13. 13

    MVC 4 Redirect when session ends

  14. 14

    Redirect after confirmation in ASP.NET WEP API controller

  15. 15

    ASP.NET MVC 5 Wrong Redirect Login Page

  16. 16

    Redirect to page OnActionExecuting method ASP.NET Core 5 MVC

  17. 17

    ASP.NET MVC 3 Redirect Requests to Root Page

  18. 18

    ASP.NET MVC 3 Redirect Requests to Root Page

  19. 19

    Redirect Page based on dropdown information in ASp.NET mvc

  20. 20

    ASP.NET MVC SqlException does not redirect to error page

  21. 21

    Redirecting to the same page with different redirect parameters in ASP.NET

  22. 22

    Redirect to specific page after session expires (MVC4)

  23. 23

    Refresh part of page after successful user sign in (ASP.NET MVC4)

  24. 24

    Redirect user after authentication with OpenIdConnect in ASP.Net MVC

  25. 25

    Data is not displayed after Page Redirect ASP.NET C#

  26. 26

    Return different views same controller in ASP.NET MVC

  27. 27

    after submit redirect to the same page

  28. 28

    Parsing json in ASP.NET MVC4 controller

  29. 29

    ASP.NET - MVC 4 using a variable from a controller to a view

HotTag

Archive