Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:56:19+00:00 2026-06-06T23:56:19+00:00

I am trying to return a different view from my controller. However, although the

  • 0

I am trying to return a different view from my controller. However, although the correct view is displayed the URL stays same.

This is my form in /Company/Create view.

@using (Html.BeginForm("Create", "Company", FormMethod.Post)) 
{ 
 // Form here
}

So basically, the form and model is submitted to /Company/Create action. If the submitted model is valid, then I process the data and redirect to /Company/Index view with

return View("Index");

As I said, correct view is displayed however, URL (address bar) is still http://.../Company/Create

I tried RedirectToAction("Index"); It does not work also. And I do not think its a good MVC practice. I have a single layout and Company views are rendered with RenderBody()

Any ideas ?

Thanks.

Edit :

This is my action method,

[HttpPost]
public ActionResult Create(CompanyCreate model)
{
    /* Fill model with countries again */
    model.FillCountries();

    if (ModelState.IsValid)
    {
        /* Save it to database */
        unitOfWork.CompanyRepository.InsertCompany(model.Company);
        unitOfWork.Save();
        RedirectToAction("Index");
        return View();
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:56:20+00:00Added an answer on June 6, 2026 at 11:56 pm

    You need to redirect to another action if you want the url changed.

    However RedirectToAction doesn’t redirect instantly but returns aRedirectToRouteResult object which is an ActionResult object.

    So you just need to return the result of RedirectToAction from your action:

    [HttpPost]
    public ActionResult Create(CompanyCreate model)
    {
        /* Fill model with countries again */
        model.FillCountries();
    
        if (ModelState.IsValid)
        {
            /* Save it to database */
            unitOfWork.CompanyRepository.InsertCompany(model.Company);
            unitOfWork.Save();
            return RedirectToAction("Index");
        }
    
        // If we got this far, something failed, redisplay form
        return View(model);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem as I want to render view from different controller and
I'm trying to return a different view if a condition is met. I want
Im trying to return the value that a $ajax call returns, from a function
I am trying to return two json sets from java which each contain key/value
I am trying to learn Asp.net mvc. I know its different from forms and
I'm trying to share an NSArray object between several different view controllers and my
I´m trying to redirect to an action from one controller to another if something
I'm trying to bind columns from two different tables in to gridview using Linq
Im trying to return a SimpleQuery list that queries a single table and uses
Am trying to return the sum of each day of a week in mysql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.