I am just learning about the Web API access and I am using it in place of my prior WCF Service to provide RESTful access to numerous business layer methods. This is within the context of a larger ASP.NET website that provides administrative tools to control
the data being accessed through REST. To this latter end, I use the Application object extensively to hold infomration for rapid retrieval.
In prior version of WCF if I set the AspNetCompatibilityRequirements to Required, I would gain access to the Application object. I do not see such an option in the new Web API options and the HttpContext.Current object is null.
Is there a way to access the same Application object as is being used i nthe main ASP.NET application?
If you're using it for caching, then I'd suggest looking into the caching APIs (like MemoryCache) built into .NET itself (rather than on the ASP.NET Application).
Thank you for responding - ended up being a stupid error. There was a Session object nested in the business logic which obviously fails every time!
One other question, my methods are returning XML strings so there is really nothing for the framework to do per se. That said, it IS doing things I do not want. First it is placing an apostrophe at the beginning and end of the XML. Also it is escpaing
any apostrophes it does find in the XML. Is there some way to turn this feature off?
One other question, my methods are returning XML strings so there is really nothing for the framework to do per se. That said, it IS doing things I do not want. First it is placing an apostrophe at the beginning and end of the XML. Also it is escpaing
any apostrophes it does find in the XML. Is there some way to turn this feature off?
I'm not sure that exact issue, but if you're using WebAPI then why not let it take the data and serialize it? That way you'll get both XML and JSON support.
tolakc
Member
5 Points
8 Posts
Application Object
Dec 18, 2012 03:48 PM|LINK
I am just learning about the Web API access and I am using it in place of my prior WCF Service to provide RESTful access to numerous business layer methods. This is within the context of a larger ASP.NET website that provides administrative tools to control the data being accessed through REST. To this latter end, I use the Application object extensively to hold infomration for rapid retrieval.
In prior version of WCF if I set the AspNetCompatibilityRequirements to Required, I would gain access to the Application object. I do not see such an option in the new Web API options and the HttpContext.Current object is null.
Is there a way to access the same Application object as is being used i nthe main ASP.NET application?
BrockAllen
All-Star
27516 Points
4897 Posts
MVP
Re: Application Object
Dec 18, 2012 04:20 PM|LINK
If you're using it for caching, then I'd suggest looking into the caching APIs (like MemoryCache) built into .NET itself (rather than on the ASP.NET Application).
http://msdn.microsoft.com/en-us/library/vstudio/dd780634%28v=vs.100%29.aspx
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
tolakc
Member
5 Points
8 Posts
Re: Application Object
Dec 18, 2012 05:17 PM|LINK
Thank you for responding - ended up being a stupid error. There was a Session object nested in the business logic which obviously fails every time!
One other question, my methods are returning XML strings so there is really nothing for the framework to do per se. That said, it IS doing things I do not want. First it is placing an apostrophe at the beginning and end of the XML. Also it is escpaing any apostrophes it does find in the XML. Is there some way to turn this feature off?
BrockAllen
All-Star
27516 Points
4897 Posts
MVP
Re: Application Object
Dec 18, 2012 05:30 PM|LINK
Ok, that's a fairly bad idea. And even for browser-based apps, I recommend against session.
I'm not sure that exact issue, but if you're using WebAPI then why not let it take the data and serialize it? That way you'll get both XML and JSON support.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/