WebException NotFound Received When Using Silverlight With MVC?

Jan 11, 2011

I'm not entirely sure how to explain this, but basically I am trying to use a Silverlight application hosted within an ASP.NET MVC application. I have a basic controller on the MVC side that contains a method which accepts some string parameter and returns an ActionResult (for the purpose of this program, that result is some Json data).

My problem arises when I handle the WebClient.OpenReadCompleted event within the Silverlight control. When the WebClient.OpenReadAsync method is called within this control, it successfully reaches the controller and then reports back to the relevant event handler as expected. However, when it is handled, the event arguments contain an error stating: "The remote server returned an error: NotFound.".

Previously, I have noticed this is caused when some part of my communication URL is incorrect - in this case it is not. From some Googling, I have also noticed that this is a generic error. As such, I'm rather stumped. To make matters more confusing, I use this exact same communication attempt in another part of the program, that retrieves an array of strings, and that works perfectly fine.

see the example code below (due to the nature of this program, I am unable to post the full code).

Silverlight Control
WebClient mClient = new WebClient();
public void RequestData()
{
mClient.OpenReadAsync(new Uri("http://localhost:51234/Home/GetData"));
mClient.OpenReadCompleted += new OpenReadCompletedEventHandler(mClient_OpenReadCompleted);
}
private void mClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if(!e.Cancelled && e.Error == null) // <-- e.Error here is a WebException
{
var serializer = new DataContractJsonSerializer(typeof(Data));
Data data = (Data)serializer.ReadObject(e.Result);
}
}

MVC Controller - named HomeController and accessed with "Home"

public ActionResult GetData()
{
return Json(new Data(), JsonRequestBehaviour.AllowGet);
}

Note Here, Data contains three members of types; string, string and byte array. For the purpose of serialization, I have exposed all three members through public properties containing both get and set parts. I have also added a public constructor taking no arguments.

UPDATE

I've just tried the same bit of code with different data, and it works fine. I wondered if it was the size of the data (as the first attempt was with very large data), but I don't understand why that would matter if the call managed to hit the controller.

View 1 Replies


Similar Messages:

C# - WebException In GetResponse() / Error:(404) Not Found"?

Dec 13, 2010

here my code-

private string HttpContent(string url)
{
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
}

exception comes in 2nd line in objRequest.GetResponse(). If I open it quick watch window I get:

'objRequest.GetResponse()' threw an exception of type 'System.Net.WebException'
"The remote server returned an error:(404) Not Found."

View 5 Replies

Data Controls :: Display Default Image (NotFound) When Image Does Not Exist In GridView?

Aug 30, 2012

i have gridview in my page

<asp:TemplateField ItemStyle-Width = "25px" HeaderText = "" ItemStyle-Height="18px" HeaderStyle-Height="18px" ItemStyle-HorizontalAlign="left">
<ItemTemplate>
<asp:Label ID="lblType" runat="server" Text='<%# Eval("price") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

i want if there wasn't any data in database, I want to display not found message

View 1 Replies

Web Forms :: Display Default Image (NotFound) When Image Does Not Exist In Database

Mar 28, 2013

This code retrieve image from SQL database i want to add code if image is not exist retrieve another image in null value 

protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
string connectionString = WebConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);

[Code] ....

View 1 Replies

C# - WebException Could Not Establish Trust Relationship For The SSL/TLS Secure Channel

Dec 20, 2010

My company has developed a .NET web service and a client dll that uses that web service. The webservice is hosted on our server over ssl and the cert is provided and signed by GoDaddy. We have some clients in a hosted environment that are getting the following error message from the client dll when it tries to access our web service.

System.Net.WebException The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Our fix has been to have them open IE on the server, which is a challenge in and of itself for a lot of the hosted services, and go to the WSDL url. IE then prompts them with a security alert dialog. It says the cert date is valid and a valid name matching the name of the page, but was issued by a company you have not chosen to trust. When they click Yes to proceed, the client dll can then succesfully connect to the web service and operate as normal. why GoDaddy would not have been in there valid publishers list? All of the servers we have running has GoDaddy as a valid authority. I'm guessing, for security reasons, they've uninstalled the authority for GoDaddy, but not totally convinced that there's not some other underlying issue.

Unfortunately, I haven't had much luck trying to recreate this locally. If I go into Internet Options and remove the GoDaddy authorities and hit our service, ssl works just fine. I go back into the list of publishers and GoDaddy gets put right back in. So my second question is, How the heck do you get rid of GoDaddy so I can get an invalid cert warning?

Okay, last question. Is there a way in code I can tell the web service to ignore invalid certs. I've seen some posts on doing this programatically with WCF but not old web services.

View 2 Replies

Exception - HttpWebResponse - How Can I Not Depend On WebException For Flow Control?

Jun 9, 2010

I need to check whether the request will return a 500 Server Internal Error or not (so getting the error is expected). I'm doing this:

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "GET";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
if (response.StatusCode == HttpStatusCode.OK)
return true;
else
return false;

But when I get the 500 Internal Server Error, a WebException is thrown, and I don't want to depend on it to control the application flow - how can this be done?

View 2 Replies

Exception Details: System.Net.WebException: The Operation Has Timed Out?

Nov 1, 2010

I have a web page that uses System.Net.HttpWebRequest class that used to work perfectly fine for 2 years, and then all of a sudden I started to get the following error.[WebException: The operation has timed out] System.Net.HttpWebRequest.GetResponse() +5314029Also, I tried the application on my local machine and it works fine, do you think it is a setting change on my hosting server?I already tried the response.close and it didn't work.

View 10 Replies

Security :: Page Caused The Following Exception: System.Net.WebException: The Remote Name Could Not Be Resolved

Feb 3, 2010

I'm using password retrieval to attempt to send their password in an email

The page caused the following exception: System.Net.WebException: The remote name could not be resolved: [URL]

My webconfig file is as follows view plaincopy to clipboardprint?

View 3 Replies

C# - WebException: The Server Committed A Protocol Violation. Section=ResponseStatusLine (call Marketo SOAP API)

Nov 25, 2010

I successfully added the web service reference and tried to call it with this line of code:SuccessGetLead lead = service.getLead(paramsgetlead);

[WebException: The server committed a protocol violation. Section=ResponseStatusLine]
System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) +263
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) +4
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +172
com.marketo.soap.MktMktowsApiService.getLead(ParamsGetLead paramsGetLead) in c:Usershubert.griningerAppDataLocalTempTemporary ASP.NET Filesdynaweb200782e21235d41bf12aApp_WebReferences.liqikruc.7.cs:206
[code]...

View 1 Replies

File Upload Error/exception Details: System.bet .webexception. Unable To Connect To The Remote Server

Mar 2, 2010

I had this one working a while back i try to upload file to my root folder it works locally but when i try it from my website i get the following error: exception details: system.bet .webexception. unable to connect to the remote server

the code bomb at the following line

requestStream = uploadRequest.GetRequestStream() 'This is where the exception occurs
fileStream = File.Open(localFile, FileMode.Open)
[code]....

View 2 Replies

WCF / ASMX :: System.Net.WebException - "The Operation Has Timed Out"

May 3, 2010

I know this has been asked umpteen times but i cant find an answer to my problem. Very simply, i have a webservice client which is trying to call a webservice. The webservice may take any time from 5mins to 30mins (or more) for downloading message data from pop3 server . However after 2mins i get the following error:

System.Net.WebException: The operation has timed-out

This is an issue with the webservice client timing out calling the webservice - as the underlying webservice still runs in the background
Sequence osf steps when the error occurs:

1.User logins with his credentials
2.Webservice client calls webservice to connect to pop3 server and download messages for that particular user.

Code in webservice for downloading data from pop3 server where the exception occurs

private string ReadOutput(bool bMultiline)
{
try
{
StreamReader srReader = new StreamReader(conn);
string strRet = srReader.ReadLine();
if (bMultiline)
{
// Example #4: Append new text to an existing file
string strLine = "";
while (true)
{
// In a multiline message the . indicates end of message
if (strLine == ".")
break;
// Relay will convert any line with just a . in it to ..
if (strLine == "..")
strLine = ".";
strRet += "
" + strLine;
}
}
return strRet;
}
catch (Exception e)
{
return null;
}
}

3.Exception is caught in webservice client while webservice continues to run.This exception occurs only when the user receives a large message may be above 1mb because i tested with 1MB msg file where i dint have any problem receiving or downloading from
pop3 server where as with 5 MB message file i got this exception .

After going through couple of forums i tested my luck by changing web.config in both webservice and webservice client where i set the attribute of httpruntime Execution timeout to 300 seconds with no success <httpRuntime

executionTimeout="300"></httpRuntime>.

I have this webservice client and webservice running on localmachine(OS-Windows Vista)

View 3 Replies

Web Forms :: How To Know What Response Is Received

Sep 23, 2010

My app will be making some API calls to a service provider's app. It's all via HTTP calls. If my call succeeds, I will receive a response which will include an HTTP response code as well as some data in the body of the response. Two questions:How do I know what response I received i.e. 201, 404, etc.In the body, I'm expecting a JSON object.

View 1 Replies

Web Forms :: Mail Not Received At The Other End?

Sep 25, 2010

using asp.net & ssytem.net.mail for sending mail

mail is being sent frm my end but the mail is not been received

View 4 Replies

Web Forms :: When The Message Received It Delivered As It Is

Jan 30, 2011

I have used the code below to send the html formatted email

[code]

BUT the problem is when i the message received it delivered as it is:

<b>Hi</b>George<br /><b>Hw r u/b>

View 2 Replies

Spaces Being Removed From String When Received?

May 26, 2010

I am attempting to pass a small xml doc as a string to an affiliate's classic asp page. Here is how I am doing it:

[Code]....

However, when they receive this info the spaces are stripped out of the xml tag causing it to not parse and be invalid. Here is what it looks like when it arrives:

<?xmlversion="1.0"encoding="utf-8"?><test_ping><id>123456789</id><zipcode>99998</zipcode><income>3200</income><dob></dob><source>affiliate1</source></test_ping>

View 8 Replies

WCF / ASMX :: Confirmation Of Send And Received XML

Feb 16, 2011

possibility of my webserver, by sending the xml to my customer indicate that was sent and received successfully.

View 1 Replies

Program To Send Out Alerts If No File Is Received?

Sep 22, 2010

I want to write a program that keeps looking out for a file in a folder. That file will be dropped in at a particular time. If no file is recieved at that time, I will have to send out an email saying no file is recieved. How can I do this?

View 1 Replies

Security :: How To Respond To HTTP Post Received From Outside

May 11, 2010

I need to allow the outsite users to login to my CMS through HTTP Post method.

My question is:

How shall I respond to the received requests and what I will return?

View 5 Replies

Visual Studio :: PasswordRecovery Email Never Received

Jan 18, 2010

I'm working on a project in VS 2010 that was created in VS 2005 & 2008. I am using the standard PasswordRecovery control. When a goes through the password recovery process, everything appears to be normal. They enter their user name, have to answer the security question, then the "Your password has been sent to you" message is displayed. But, the email is never received. I have tried user names with several different email addresses, but no messages are received. What is a good way to debug this? Here are my settings:

In web.config:
<appSettings>
<!-- The following line is set up for Gmail (otherwise, value="localhost") -->
<add key="MailServer" value="[URL]"/>...

Membership Provider:
<providers><add name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SiteConnection" applicationName="/" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"/></providers>...

Also, all of the other emails generated from my site are being sent and received successfully.

View 6 Replies

C# - How To Detect That A File Was Successfully Received By A Webclient

Feb 18, 2010

My question is similar to http://stackoverflow.com/questions/194579/how-to-detect-when-a-user-has-successfully-finished-downloading-a-file-in-php but I have to do the same using IIS, ASP.NET and C#.

None of the methods in the HttpResponse class provide feedback if the data was sent or not, TransmitFile just does its job (or not) and does not provide any means of knowing the result.I was thinking of using the .Filter property but then again, the filter is based on the HttpResponseStream which does also not provide any feedback.

View 2 Replies

Determine How Many Bytes Of A Request Have Been Read/received

Apr 5, 2010

Just wondering if anyone has any idea how you can determine how many bytes of a request have been read/received by the server... In other words how do I stream http request...

In that, users are uploading files and I want to report on a perotic basis how many bytes have been read/received so far.

View 2 Replies

Web Forms :: Mail Not Received From Mailing Module?

Sep 7, 2010

i am sending mail thr' asp.net using System.Net.Maili am not getting any error msg but nor am i getting the mailsi hae sent it to yahoo, gmail & rediff ids but mail is not recivedhow do i check out if there is any prblm on my end code or why its not been senti have used Catch smtpExc As System.Net.Mail.SmtpException for checking out any exeption

View 7 Replies

Security :: Displaying Html Received Via Post?

May 17, 2010

I created a page that receives an html report from post data. This html is split up into pages and displayed in divs (as well as used to create a .pdf file but I don't think that is a security risk if the displaying it isnt a risk).

My concern is that I had to set ValidateRequest="false" in order to be able to do this. If the page somehow received malicious input with a serverside script or something, would the script run / could this be dangerous?

This is how I'm handling the request: I have a div with runat="server." Then, in the page_load event (i'm using vb.net codebehind) i set the div.innerHTML property to a modified version of the html received via post.

View 2 Replies

Web Forms :: The Message Received From The Server Could Not Be Parsed?

Aug 16, 2010

I have used asp.net wizard inside update panel. Well in this, i have used combo box in second wizard and i have assigned integer character to combo. This gives an error while i press next button. But this works in 1st wizard page fine if i load it for the first time. For this code is as below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WizardTest.aspx.cs" Inherits="WizardTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

[code]...

View 7 Replies

Web Forms :: How To Populate Menu With The Names Of Received Foldernames

Aug 23, 2010

I want to get the names of some folders in my drive and populate my menu control with the names of those folders.

Getting the folder names is not the issue, but how can i populate my menu with the names of get foldernames.

[Code]....

But im getting the error:

HierarchicalDataBoundControl only accepts data sources that implement IHierarchicalDataSource or IHierarchicalEnumerable.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved