I want to make some Sitecore data available to a non-Sitecore page. The data will be requested by JQuery and should be in JSON format. We will also need to update items, execute workflow actions, etc.
We are on Sitecore 6.4 so, as I understand it, we don't have ItemWebAPI or MVC available as options. .NET is version 4
We tried doing it with a GET request, looking at query string parameters and branching to one function or another. One problem was that the default max size of the query string was way too small for the data we are passing, and setting it to the max allowed (which is apparently against security best practices) is also not reliably enough. So for that reason and some cache-related issues we moved to POST. JQuery couldn't seem to send POST data in the way the page wanted to get it, so we had to introduce some code to parse the request payload text (i.e. we couldn't use Request.Form["something"]). We did get this working but it is ugly. Between that and the branching it is a tangle.
I am now looking at WebMethods. In addition to simplifying the code, WebMethods also give us some free stuff like error messages in json format, sensible error messages for missing params, etc.
I have a test page set up to make requests (just HTML and JQuery) and an ASPX page to do the WebMethods. I put the URL of the WebMethods page in the web.config's IgnoreUrlPrefixes as described here: WebMethod not accessible in Sitecore . I can get to the Sitecore databases by using Sitecore.Configuration.Factory.GetDatabase(databasename).
So WebMethods overall seem to be better to code and work better than what we had before. Now I can read the code and I am just writing functions that work instead of spending most of my time figuring out why things aren't working and implementing workarounds.
But we do lose the Sitecore context, as described in the answer to the referenced question. I have not been able to find a way to get the Sitecore user.
I can see in Chrome Developer Tools when I make a request that there is a sitecore_userticket cookie going out with the request. I have tried feeding the value of that cookie (as well as the result of Sitecore.Web.Authentication.TicketManager.GetCurrentTicketId) to Sitecore.Web.Authentication.Ticket.Parse but I get a parse error. Is there a way to use that cookie to get the user?
Or is there a way to get the user from the ASP.NET_SessionId cookie?
If neither of those are workable, what would be a good way to manage login info? I am aware that I can log a user in programmatically but would prefer not to track the Sitecore username and password in the browser and send them with every request.
I don't have much experience with .NET outside of Sitecore.