User-540818677 posted
I am working on an asp.net MVC core web application, and i have the following routing rules:-
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "IP",
pattern: "IP/{controller=Home}/{action=Index}/{id?}");
});
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "Info",
pattern: "Info/{controller=Home}/{action=Index}/{id?}");
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
then inside my create form i define the following to use different url when posting back the form depending on the current url:-
<form method="post" action="@(!Context.Request.Path.Value.ToString().ToLower().Contains("/info") ? "/IP/submissions/create/": "/info/submissions/create/")" >
and here is my post action method:-
[AllowAnonymous]
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Submission,SubmissionQuestionSubmission")] SubmissionCreate sc )
{
but currently when i post back the form the action method will not be called... any idea? and the browser console will raise this error:-
HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax.
POST - https://localhost:44363/info/Submissions/Create/