http://localhost:53435/Blog/BlogIndex?title=blog+title&seo=seo&content=%3Cp%3Econtent%3C%2Fp%3E%0D%0A
the URL listed above
Whenever I click the save button, the page refreshes and the URL appears like that.
I do not want it, how can I resolve this issue?
This is my controller code:
try
{
Blog addModel = new Blog();
content = content.Replace("<p>", "").Replace("</p>", "");
addModel.BlogPictureURL = pictureData;
addModel.BlogContent = content;
addModel.BlogPictureSEO = seo;
addModel.BlogTitle = title;
addModel.BlogDate = DateTime.Today;
addModel.BlogViewCount = 0;
db.Blog.Add(addModel);
db.SaveChanges();
var lastID = db.Blog.OrderByDescending(x => x.ID).Take(1).FirstOrDefault().ID;
foreach (var item in Tags)
{
Tags newTag = new Tags();
newTag.TagsName = item;
newTag.BlogID = lastID;
db.Tags.Add(newTag);
}
db.SaveChanges();
return RedirectToAction("BlogIndex", "Blog");
}
catch
{
return RedirectToAction("Error", "Admin");
}
This is my AJAX code:
function SaveAllData() {
var blogFile;
var elem = $(".dz-details").find("img");
blogFile = elem[0].getAttribute("alt");
var elemData = $("#tags").val();
elemData = elemData.split(",");
$.ajax({
type: "POST",
url: "/Blog/AddBlog",
datatype: "json",
traditional: true,
data: {
title: $("#title").val(),
seo: $("#seo").val(),
content: CKEDITOR.instances.content.getData(),
Tags: elemData,
pictureData: blogFile
}
});
}
If I perform this action without an AJAX post, there are no issues But when using AJAX, something goes wrong.