Click here to Skip to main content
15,885,216 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to convert PDF to JPEG PinPopular
Richard MacCutchan9-Sep-13 23:45
mveRichard MacCutchan9-Sep-13 23:45 
GeneralRe: How to convert PDF to JPEG Pin
bths10-Sep-13 1:27
bths10-Sep-13 1:27 
GeneralRe: How to convert PDF to JPEG Pin
Richard MacCutchan10-Sep-13 5:05
mveRichard MacCutchan10-Sep-13 5:05 
AnswerRe: How to convert PDF to JPEG Pin
Richard Deeming10-Sep-13 1:03
mveRichard Deeming10-Sep-13 1:03 
GeneralRe: How to convert PDF to JPEG Pin
Ghost Leader16-Sep-13 21:09
Ghost Leader16-Sep-13 21:09 
QuestionHow do I fix "This page can't be displayed" error in asp.net c#? Pin
Xarzu9-Sep-13 10:13
Xarzu9-Sep-13 10:13 
AnswerRe: How do I fix "This page can't be displayed" error in asp.net c#? Pin
Richard Deeming10-Sep-13 1:00
mveRichard Deeming10-Sep-13 1:00 
QuestionRetreive JSON Data from HttpRequestMessage Pin
AnalogNerd9-Sep-13 6:53
AnalogNerd9-Sep-13 6:53 
I'm doing a post to a WebAPI that passes a JSON object. Here's how the Post is set up:

C#
var jsonContent = new JavaScriptSerializer().Serialize(myObject);
var request = (HttpWebRequest)WebRequest.Create(apiUrl);
request.Date = dateOffset.DateTime;
request.Method = method;
using (var streamWriter = new StreamWriter request.GetRequestStream()))
    {
        streamWriter.Write(jsonContent)
        streamWriter.Flush();
        streamWriter.Close();
    }
}


In my WebAPI I have an attribute on my controller that inherits from ActionFilterAttribute. This serves to do some authentication and security checks before the controller is called.

Ideally I'd like to retrieve the JSON string from the Request, but I can't figure out how.

I tried this, but it didn't work:
C#
var contentTask = actionContext.Request.Content.ReadAsStringAsync();
contentTask.Wait();
var jsonContent = contentTask.Result;


However, the content is always empty. What am I doing wrong?

EDIT: For what it is worth, if I comment out this problematic code and let the call go on to my controller, the object is passed in and deserialized just fine.
QuestionSecuring asmx web service for JS Pin
SerNovik9-Sep-13 1:43
SerNovik9-Sep-13 1:43 
AnswerRe: Securing asmx web service for JS Pin
Abhinav S9-Sep-13 6:57
Abhinav S9-Sep-13 6:57 
QuestionDeploying MVC 4 Intranet on IIS Pin
nitin_ion8-Sep-13 21:01
nitin_ion8-Sep-13 21:01 
AnswerRe: Deploying MVC 4 Intranet on IIS Pin
Abhinav S9-Sep-13 6:58
Abhinav S9-Sep-13 6:58 
QuestionCheckbox in the Gridview in asp.net application using VS 2005 & Or VS 2008 Pin
dash20208-Sep-13 19:46
dash20208-Sep-13 19:46 
QuestionjQuery jTable update : data base side won't be updated Pin
Member 101874186-Sep-13 9:25
Member 101874186-Sep-13 9:25 
QuestionCalendar control in month view,week view and day view Pin
Member 102290555-Sep-13 20:20
Member 102290555-Sep-13 20:20 
GeneralRe: Calendar control in month view,week view and day view Pin
Richard MacCutchan5-Sep-13 22:23
mveRichard MacCutchan5-Sep-13 22:23 
QuestionMULTI LANGUAGE WEBSITE IN ASP.NET USING C# Pin
abdul subhan mohammed5-Sep-13 4:33
professionalabdul subhan mohammed5-Sep-13 4:33 
AnswerRe: MULTI LANGUAGE WEBSITE IN ASP.NET USING C# Pin
Forbiddenx6-Sep-13 7:04
Forbiddenx6-Sep-13 7:04 
AnswerRe: MULTI LANGUAGE WEBSITE IN ASP.NET USING C# Pin
Abhinav S8-Sep-13 18:15
Abhinav S8-Sep-13 18:15 
Questionupdate a formview that allows paging (dynamic data website)‏ Pin
marounmm5-Sep-13 3:24
marounmm5-Sep-13 3:24 
AnswerRe: update a formview that allows paging (dynamic data website)‏ Pin
Codes DeCodes10-Sep-13 0:46
Codes DeCodes10-Sep-13 0:46 
Questionradio button Pin
Member 102315013-Sep-13 23:08
Member 102315013-Sep-13 23:08 
AnswerRe: radio button Pin
TheUltimateDebugger3-Sep-13 23:15
professionalTheUltimateDebugger3-Sep-13 23:15 
AnswerRe: radio button Pin
Bernhard Hiller3-Sep-13 23:17
Bernhard Hiller3-Sep-13 23:17 
AnswerRe: radio button Pin
jitendra kumar upadhyay5-Sep-13 1:47
jitendra kumar upadhyay5-Sep-13 1:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.