TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Laxman Dussa
NA
117
4.3k
mvc with webapi
Jun 11 2019 11:47 PM
public
static
string
DoWebreqeust(
string
url,
string
json)
{
try
{
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(url); request.KeepAlive =
false
;
request.ProtocolVersion = HttpVersion.Version10;
request.Method =
"POST"
;
byte
[] postBytes = Encoding.UTF8.GetBytes(json);
request.ContentType =
"application/json; charset=UTF-8"
;
request.Accept =
"application/json"
;
// request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
//error line
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string
result;
using
(StreamReader rdr =
new
StreamReader(response.GetResponseStream()))
{
result = rdr.ReadToEnd();
}
return
result;
}
catch
(Exception ex)
{
return
""
;
}
}
above code
i send a 3 pdf files with base64 data to api
'responseStream.Length' threw an exception of type 'System.NotSupportedException'.
Length = 'dataStream.Length' threw an exception of type 'System.NotSupportedException'
Position = 'dataStream.Position' threw an exception of type 'System.NotSupportedException'
Reply
Answers (
5
)
JQuery Searchable DDL inside Datagrid
Open PDF File from a specific Page using ITextSharp Asp.net