Error trying to post data to a page in v12 and retrieving using Request.Form
Hi,
I have a form on one of my Umbraco pages which posts back to itself (it's for a filter)
I have done this before on earlier versions of Umbraco but it's just not allowing me to do this on Version 12
var formFilterKeyword = Request.Form["Keyword"].ToString();
I am getting this error:
error CS0103: The name 'Request' does not exist in the current context"
when trying to get the keyword from the form field using the code above. As I said, I have used this before on v8. I realise this is likely to be a new .net core issue, how would I do it on v12? Looking for the simplest solution.
Thank you for the reply, It's taken me a while to get back round to this, but still get an error:
> System.InvalidOperationException: Incorrect Content-Type: at
> Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm() at
> AspNetCore.Views_Contact.ExecuteAsync() in
> C:\inetpub\wwwroot\UmbracoLive\myproject\live\Views\form.cshtml:line
> 11 at
> Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage
> page, ViewContext context) at
> Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage
> page, ViewContext context, Boolean invokeViewStarts) at
> Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext
> context) at
> Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext
> viewContext, String contentType, Nullable`1 statusCode) at
> Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext
> viewContext, String contentType, Nullable`1 statusCode) at
> Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext
> actionContext, IView view, ViewDataDictionary viewData,
> ITempDataDictionary tempData, String contentType, Nullable`1
> statusCode) at
> Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext
> context, ViewResult result) at
> Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext
> context) at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker
> invoker, Task lastTask, State next, Scope scope, Object state, Boolean
> isCompleted) at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed
> context) at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State&
> next, Scope& scope, Object& state, Boolean& isCompleted) at
> Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
I used to have no problems doing this with V8 but it's really frustrating? I've seen lots of posts online suggesting something similar to your suggestion above, none of them seem to work at all? Any Idea?
Error trying to post data to a page in v12 and retrieving using Request.Form
Hi,
I have a form on one of my Umbraco pages which posts back to itself (it's for a filter)
I have done this before on earlier versions of Umbraco but it's just not allowing me to do this on Version 12
I am getting this error:
error CS0103: The name 'Request' does not exist in the current context"
when trying to get the keyword from the form field using the code above. As I said, I have used this before on v8. I realise this is likely to be a new .net core issue, how would I do it on v12? Looking for the simplest solution.
Thanks in advance :)
I think you have 2 ways
or
Hi,
Thank you for the reply, It's taken me a while to get back round to this, but still get an error:
I used to have no problems doing this with V8 but it's really frustrating? I've seen lots of posts online suggesting something similar to your suggestion above, none of them seem to work at all? Any Idea?
is working on a reply...