HttpContext, alternative approach to Context.Request.Unvalidated for pre .Net 4.5 servers
.net, c#
Solution
I don't know weither you are using MVC or Web Forms/Web Pages, but there are several solutions available for you. Take a look at this MSDN page for more info about disabling request validation.
Web Forms: add `<@ Page validateRequest="false" %>` to the top of your page to disable validation for a single page (other options for more pages/parts of an application are in the MSDN page).
MVC: add attribute `[ValidateInput(false)]` to the top of your action OR add an `[AllowHtml]` attribute to the property in the model you are binding to.
Problem
I have a method in my project as per below which takes a `HttpContext` object and returns a `string`. ``` //returns the xml document as string private static string GetXmlReceiptFromContext(HttpContext context) { context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.Cache.SetNoStore(); context.Response.Cache.SetExpires(DateTime.MinValue); return context.Request.Unvalidated.Form.Get("status"); } ``` The result of this is ultimately passed into a very important method that requires this string. It appears that `Context.Request.Unvalidated` is only available from .Net 4.5. I need to alternative approach to this method for our servers which do not have .Net 4.5 and will be making use of this assembly. Can anyone suggest an alternative way of accessing and returning the status parameter who's value will be an XML Document from the context without using Context.Request.Unvalidated? edit This is not for a webform or MVC project, we have developed a class library whch we ideally want to contain all the payment related features within the assembly, i.e. single responsibility, our front end apps which will be using this do not need to know about the payment side of things.