question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Core minification not working for form HttpPost

See original GitHub issue

I’ve followed instructions to implement AspNetCore1 2.3.0 into .NET Core web app. Minification works fine except for single scenario.

I’ve made a simple form that posts to controller, after the post page source isn’t minified.

public class SampleController : Controller
{
    [HttpGet]
    public IActionResult Verify()
    {
        return View(); // Minified
    }

    [HttpPost]
    public IActionResult Verify(FoundersVerifyViewModel viewModel)
    {
        ModelState.AddModelError(string.Empty, "Form posted.");
        return View(); // No minification
    }
}

And the view

@Html.ValidationSummary()
<form asp-controller="Sample" asp-action="Verify" method="post" class="form-horizontal">
    <button type="submit" class="btn btn-default">Verify</button>
</form>

You can’t notice this with “View Page Source” as it makes new request to the page, but it’s apparent if your page displays differently minified/unminified or if you have comments in the html which after form post will appear in the developer tools.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Taritsyncommented, May 8, 2017

@aras777 @Xeevis This problem is solved in version 2.4.0.

Use the following settings:

services.AddWebMarkupMin(options =>
	{
		…
	})
	.AddHtmlMinification(options =>
	{
		options.SupportedHttpMethods = new HashSet<string> { "GET", "POST" };
		…
	})
	…
	;
1reaction
aras777commented, Apr 29, 2017

Anyway I was able to fix it by adding line inside post action “Request.Method = “GET”;”, dirty workaround but works till next release 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Bundle Minification not working when publishing ...
Turns out it was ASP.NET form authentication. As according to this, the name of the bundle should not be an existing directory.
Read more >
the form Http POST doesn't work, only Get work in asp core ...
I have a Form that should pass data through POST request, but GET request is being used without passing the data and do...
Read more >
How we do bundling and minification in ASP.NET Core
The solution suggested in this post is based on not building the minified bundles locally. In theory, this means that the .min files...
Read more >
A Step by Step Guide to Bundling and Minification in ASP. ...
Learn how to configure Bundling and Minification in ASP.NET and how to use BuildBundlerMinifier Package and Bundler and Minifier VS ...
Read more >
Options for CSS and JS Bundling and Minification with ASP ...
I'm in Visual Studio 2017 and I go File | New Project | ASP.NET Core Web App. Bundling isn't on by default but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found