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
srinivas
NA
94
569
Getting Exception while running from EXE.
Jul 20 2018 8:30 AM
HI
This is Srinivas,
I tried to getting web respone of url from Windows/console, code is working fine whle its runnning from appilication but returns exception while its running from EXE, same behaviuor follow in console appilication also.
The Error:-
The underlying connection was closed: The connection was closed unexpectedly.
Code is :-
public void GetResponse()
{
string spp = "http://www.somewebsite.in/";
String result = GetPageContent(spp);
label2.Text = result;
}
public string GetPageContent(string FullUri)
{
try
{
HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create(FullUri);
// Request response:
WebResponse Response = WebRequestObject.GetResponse();
// Open data stream:
Stream WebStream = Response.GetResponseStream();
// Create reader object:
StreamReader Reader = new StreamReader(WebStream);
// Read the entire stream content:
string PageContent = Reader.ReadToEnd();
// Cleanup
Reader.Close();
WebStream.Close();
Response.Close();
// return PageContent;
return "Success";
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}
Please help me.
Reply
Answers (
2
)
visual Studio 2015 setup file with database
Creating a group of radio buttons