0

I'm fairly new to MVC web api, and trying to get POST requests to process properly. It's mostly working, but string values are HTML-encoded. I thought this would be handled automatically, and I find no way to do this manually.

Here is the ajax request:

    $.ajax({
        url: '/api/PulseStudies/UpdateTask',
        type: 'POST',
        data: { 'userID': userid, 'taskID': CurExamTaskID, 'comment': comment, 'complete': complete },
        async: true,
...

Here is the server-side API:

[HttpPost]
public HttpResponseMessage UpdateTask(TaskResponse value)
{
    Tasks.UpdateTask(value.userID, value.taskID, value.comment, value.complete);
    return Request.CreateResponse(HttpStatusCode.NoContent);
}

public class TaskResponse
{
    public int userID { get; set; }
    public long taskID { get; set; }
    public string comment { get; set; }
    public bool complete { get; set; }
}

The comment value is HTML-encoded, e.g., "blah%20blah". How do I get a properly decoded value?

1 Answer 1

1

I believe you mean it is UrlEncoded. On the server side you want HttpServerUtility.UrlDecode() http://msdn.microsoft.com/en-us/library/6196h3wt(v=vs.110).aspx to get it back.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.