Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Remove X-Response-View

supportb00668bc5e60
diff --git a/src/Web/Grand.Web/Controllers/BasePublicController.cs b/src/Web/Grand.Web/Controllers/BasePublicController.cs
index 43c7593e6..1022fbf9a 100644
--- a/src/Web/Grand.Web/Controllers/BasePublicController.cs
+++ b/src/Web/Grand.Web/Controllers/BasePublicController.cs
@@ -18,8 +18,14 @@ namespace Grand.Web.Controllers
private bool IsJsonResponseView()
{
- var viewJson = Request?.Headers["X-Response-View"];
- return viewJson?.Equals("Json") ?? false;
+ if (Request.Method.Equals("GET", StringComparison.InvariantCultureIgnoreCase))
+ return Request.Headers.Accept.ToString()
+ .Equals("application/json", StringComparison.InvariantCultureIgnoreCase);
+
+ if (Request.Method.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
+ return Request.ContentType?.Contains("application/json") ?? false;
+
+ return false;
}
public new IActionResult View(object model)
@@ -43,4 +49,4 @@ namespace Grand.Web.Controllers
return IsJsonResponseView() ? RedirectToRoute("Route", new { routeName }) : base.RedirectToRoute(routeName);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Catalog/Partials/ModelScript.cshtml b/src/Web/Grand.Web/Views/Catalog/Partials/ModelScript.cshtml
index bd12fb2fa..a5604df36 100644
--- a/src/Web/Grand.Web/Views/Catalog/Partials/ModelScript.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/Partials/ModelScript.cshtml
@@ -21,8 +21,7 @@
const options = {
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
};
axios.get(url, options)
diff --git a/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml b/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml
index 1f41475d8..5aedc79f7 100644
--- a/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Components/ProductEmailAFriend/Default.cshtml
@@ -103,8 +103,7 @@
method: 'post',
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
}).then(function (response) {
emailafriend.Message.Result = response.data.Result;
diff --git a/src/Web/Grand.Web/Views/ShoppingCart/Partials/ModelScript.cshtml b/src/Web/Grand.Web/Views/ShoppingCart/Partials/ModelScript.cshtml
index 87108899e..a1a6542e5 100644
--- a/src/Web/Grand.Web/Views/ShoppingCart/Partials/ModelScript.cshtml
+++ b/src/Web/Grand.Web/Views/ShoppingCart/Partials/ModelScript.cshtml
@@ -39,8 +39,7 @@
data: null,
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
}).then(response => {
this.cart = response.data;
@@ -53,8 +52,7 @@
data: null,
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
}).then(response => {
this.totals = response.data;
@@ -117,8 +115,7 @@
baseURL: '@Url.RouteUrl("ShoppingCart")',
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json',
},
}).then(function (response) {
vmorder.cart = response.data;
diff --git a/src/Web/Grand.Web/Views/Wishlist/Components/EmailWishlist/Default.cshtml b/src/Web/Grand.Web/Views/Wishlist/Components/EmailWishlist/Default.cshtml
index daf50775e..479d67031 100644
--- a/src/Web/Grand.Web/Views/Wishlist/Components/EmailWishlist/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Wishlist/Components/EmailWishlist/Default.cshtml
@@ -108,8 +108,7 @@
method: 'post',
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
}).then(function (response) {
emailwishlist.Message.Result = response.data.Result;
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index e9627dbe2..9b0e651aa 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -497,8 +497,7 @@ var vm = new Vue({
params: { "productId": id },
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
}).then(function (response) {
vm.RelatedProducts = response.data;
@@ -514,8 +513,7 @@ var vm = new Vue({
method: 'post',
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
}
}).then(function (response) {
if (response.data.stockAvailability) {
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js b/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js
index 9f02d7de2..c122a56ab 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js
@@ -775,8 +775,7 @@ var vmorder = new Vue({
data: null,
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
},
showLoader: false
}).then(response => {
@@ -790,8 +789,7 @@ var vmorder = new Vue({
data: null,
headers: {
'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'X-Response-View': 'Json'
+ 'Content-Type': 'application/json'
},
showLoader: false
}).then(response => {