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 8317057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:30:04+00:00 2026-06-08T21:30:04+00:00

I’m working on the admin part of an MVC webapp. I had the idea

  • 0

I’m working on the admin part of an MVC webapp. I had the idea to use “widgets” for a single Admin panel. I’ll explain my intentions first.

I have a languages table, and for that I’d like to create a partial view with a dropdownlist for those languages and a single button “Edit”, that would take the user to a non-partial view to edit the language. After clicking save, the users would be redirected to the Index view, which would just show the dropdownlist again.

So I have a “Index.cshmtl”, and an “EditLanguage.cshtml” as non-partial views, and a “LanguageWidget.cshtml” as a partial view.

First the user sees the Index view.

    public ViewResult Index()
    {
        return View();
    }

This view has the following code in it:

@using CodeBox.Domain.Concrete.ORM
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Administration</h2>
@Html.Action("LanguageWidget")

The Partial view “LanguageWidget” just contains the following code, and when the user submits it posts to the HttpPost annotated method in my controller:

@using (Html.BeginForm("LanguageWidget", "Admin"))
{
    @Html.DropDownListFor(model => model.SelectedItem, Model.Languages)
    <input type="submit" value="Edit"/>
}

This is the HttpPost method for the widget:
[HttpPost]
public ActionResult LanguageWidget(LanguageWidgetModel model)
{
var lang = langRepo.Languages.FirstOrDefault(l => l.LanguageId == model.SelectedItem);
return View(“EditLanguage”, lang);
}

This takes the user to the language edit page, which works fine.

But then! The user edits the language and submits the page, which invokes the “EditLanguage” HttpPost method, so the language is saved properly.

    [HttpPost]
    public ViewResult EditLanguage(Language model)
    {
        if (ModelState.IsValid)
        {
            langRepo.SaveLanguage(model);
            TempData["message"] = string.Format("{0} has been saved!", model.Name);
            return View("Index");
        }
        else
        {
            return View(model);
        }
    }

So, when I return the “Index” view – which seems logical I guess – the controller still assumes this is a HttpPost request, and when it renders the Index view, it invokes the “LanguageWidget” method, assuming it has to render the HttpPost method.

This leads to the LanguageWidget HttpPost method, which returns a full view with layout, returning just that, so I have my layout, with view, containing a layout, with the editview.

I don’t really see how I could fix this?

I’m pretty sure it’s a design flaw from my part, but I can’t figure it out.

Thanks in advance!!

  • 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-08T21:30:06+00:00Added an answer on June 8, 2026 at 9:30 pm

    Consider using:

    return RedirectToAction("Index")
    

    instead of:

    return View("Index");
    

    It might seem more logical if the user is actually redirected to Index instead of
    remaining at the EditLanguage. And if the user hits the refresh button no data will be resent using this approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to create an if statement in PHP that prevents a single post

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.