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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:26:44+00:00 2026-06-04T12:26:44+00:00

In ASP.NET MVC, I have a main standard form that posts to an action,

  • 0

In ASP.NET MVC, I have a main standard form that posts to an action, and renders the response in the same view.

The problem is that the response type is coming back as application/x-javascript, and as a result the browser is rendering the HTML as text.

I’ve narrowed the issue down to being caused by the inclusion of some partial views in the master page that render forms that post back to actions returning JavaScriptResult.

When I remove these partial view references, the response type from the main form post response is text/html I want.

Why is the JavaScriptResult action interfering with the main form post. I’m not posting to this action so why would MVC decide to infer that the response content type should be application/x-javascript?

Basic Main Form:

@using (Html.BeginForm("TestSearch", "TestSearch", FormMethod.Post))
{
    ....
}

[HttpPost]
public ActionResult TestSearch(TestSearchInfo testSearchInfo)
{
    ...

    return View(testSearchInfo);
}

In the Layout page:

@{Html.RenderPartial("~/Views/Account/LoginOrRegister.cshtml");}

Which is a form that posts to...

[HttpPost]
public JavaScriptResult Login(LoginInfo loginInfo)
{
}

Update:

The core issue seems to be that when I hit the submit button for the main form, the other form which is MVC ajax enabled is posting back too, as a result, both actions are firing, and the one that returns JavaScriptResult is the one that is firing second. I’m still not sure how to prevent this behaviour…

Update:

See answer below

  • 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-04T12:26:47+00:00Added an answer on June 4, 2026 at 12:26 pm

    Answer here, hope it helps others.

    I have modified all forms that involve a JavaScript response so that the action that renders the control, traditionally the action with the HttpGet attribute to remove the HttpGet so the action can fire in both GET and POST contexts.

    This requires a rename of the action that the form posts to, so there is no ambiguity as to which method should fire.

    I guess this makes sense – what I guess I was expecting to see was that the rendering of a partial view where the contained form was not the POST target should use the get overload to render. I understand why that isn’t the way it works though.

    // No GET / POST Attribute, this can no fire in both GET and POST contexts
    public ActionResult Login()
    {
        .. This will now fire for every page load, where as before the HttpGet
           filter only allowed to run in a GET context. 
    }
    
    [HttpPost]
    public JavaScriptResult DoLogin(LoginInfo loginInfo)
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a POEAA I have a standard ASP.NET MVC View with
I have an ASP.NET MVC app that shows news articles and for the main
I have a ASP.Net MVC form that upon submit I need a couple of
On my ASP.net MVC 3.0 I have a View looks in that i have
ASP.Net MVC Controllers have several methods of forwarding control to another controller or action.
in a ASP.NET application (MVC) I have a foreach loop that loops through a
In my ASP .NET MVC application i have a link that refreshes the preview
I'm using ASP.NET MVC 2 and have a login page that is secured via
I have an ASP.NET MVC project that works fine on my local machine (no
The main page (asp.net/mvc) only seems to have a getting started guide and tutorial,

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.