A 400 error is usually returned by ASP.NET if your request fails verification. This most often occurs if you make a POST request using AJAX, but forget to include the verification token that gets generated by the BeginForm HTML helper or the form tag helper
if you are using ASP.NET Core, or you haven't generated a request token but the action/handler method expects one.
It's difficult to tell if this applies to your issue because you haven't provided any details on how you are trying to upload the image or process it.
I don't understand what a config file has to do with this. But in any event, your upload ActionResult expects an antiforgery token. The 400 result suggests that one is not being passed when the upload is attempted. You haven't shown your upload form, but
I suspect that you are not generating an antiforgery token
None
0 Points
12 Posts
upload image with ckeditor in mvc core
Jun 15, 2019 07:03 AM|Marigold|LINK
Hello . I want to upload a picture through CKeditor, but I have a 400 error. Thank you for guidance.
config file :
view code :
All-Star
194524 Points
28081 Posts
Moderator
Re: upload image with ckeditor in mvc core
Jun 17, 2019 11:51 AM|Mikesdotnetting|LINK
A 400 error is usually returned by ASP.NET if your request fails verification. This most often occurs if you make a POST request using AJAX, but forget to include the verification token that gets generated by the BeginForm HTML helper or the form tag helper if you are using ASP.NET Core, or you haven't generated a request token but the action/handler method expects one.
It's difficult to tell if this applies to your issue because you haven't provided any details on how you are trying to upload the image or process it.
More details on the verification token can be found here: https://www.learnrazorpages.com/security/request-verification. The post is about Razor Pages on .NET Core, but the principal is the same for MVC.
None
0 Points
12 Posts
Re: upload image with ckeditor in mvc core
Jun 18, 2019 06:47 PM|Marigold|LINK
Thank you so much
I built an Area "Admin" and a Controller then in Index Action :
and View Index :
and Then my action UploadImage :
and config.js :
All-Star
194524 Points
28081 Posts
Moderator
Re: upload image with ckeditor in mvc core
Jun 18, 2019 07:56 PM|Mikesdotnetting|LINK
I still can't see any code for uploading the image. Are you using a jQuery $.post ?
None
0 Points
12 Posts
Re: upload image with ckeditor in mvc core
Jun 19, 2019 05:01 AM|Marigold|LINK
no , for uploading via config file
All-Star
194524 Points
28081 Posts
Moderator
Re: upload image with ckeditor in mvc core
Jun 19, 2019 06:30 AM|Mikesdotnetting|LINK
I don't understand what a config file has to do with this. But in any event, your upload ActionResult expects an antiforgery token. The 400 result suggests that one is not being passed when the upload is attempted. You haven't shown your upload form, but I suspect that you are not generating an antiforgery token
None
0 Points
12 Posts
Re: upload image with ckeditor in mvc core
Jun 19, 2019 07:26 AM|Marigold|LINK
yes
I have added these codes but it is not correct
in view:
and in config.js :
All-Star
194524 Points
28081 Posts
Moderator
Re: upload image with ckeditor in mvc core
Jun 19, 2019 07:47 AM|Mikesdotnetting|LINK
In ASP.NET Core, the name of the header should be RequestVerificationToken, unless you have specified something else in Startup.
None
0 Points
12 Posts
Re: upload image with ckeditor in mvc core
Jun 19, 2019 07:49 AM|Marigold|LINK
I changed code to below and It 's worked :
Thank you very much
None
0 Points
12 Posts
Re: upload image with ckeditor in mvc core
Jun 19, 2019 12:26 PM|Marigold|LINK
One question is, photos are now stored in the myimage folder and their address is in ckeditor
If I want to save the URL of the ckeditor to the server, what should I do?
Should I search the entire text for the name of the photo and save any image in the database?