|
WebPageControllerPostPage Method
|
Common page post handler.
Namespace: GSF.Web.HostingAssembly: GSF.Web (in GSF.Web.dll) Version: 2.4.282-beta
Syntax
Remarks
For Ajax post-based requests to pages handled by this controller, the Ajax request will need to specify
verification token in the header and set flag that indicates an Ajax request. See example code below:
@{
// Setup AJAX based anti-forgery implementation
string verificationHeader = AuthenticationOptions.DefaultRequestVerificationToken;
string useAjaxVerfication = AuthenticationOptions.DefaultAjaxRequestVerificationToken;
ReadonlyAuthenticationOptions options = ViewBag.AuthenticationOptions;
if (options != null) {
if (!string.IsNullOrWhiteSpace(options.RequestVerificationToken)) {
verificationHeader = options.RequestVerificationToken;
}
if (!string.IsNullOrWhiteSpace(options.AjaxRequestVerificationToken)) {
useAjaxVerfication = options.AjaxRequestVerificationToken;
}
}
string verificationValue = Html.RequestVerificationHeaderToken();
string constants = string.Format(@"
const verificationHeader = ""{0}"";
const verificationValue = ""{1}"";
const useAjaxVerfication = ""{2}"";
",
/* 0 */ verificationHeader.JavaScriptEncode(),
/* 1 */ verificationValue.JavaScriptEncode(),
/* 2 */ useAjaxVerfication.JavaScriptEncode()
);
}
@section Scripts {
}
See Also