Hi,
I got a webservie that supply users with binary files based on a parameter
id. The method is void and I stream the file by:
HttpContext.Current.Response.ContentType = "application/xxx";
HttpContext.Current.Response.BinaryWrite(arrResult );
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
HttpContext.Current.Response.Close();
return;
If the parameter id is invalid or if something goes wrong I would like to
throw either 404 och 500 exception. I been tring to do this with the
following code but I will allways recieve a 500. How can I control the
output exception. 4 9094
I forgot to past some code....
HttpContext.Current.Response.StatusCode = 500;
throw new HttpException(500, "Error getting the file.\n\n" + e);
"Oscar" <xx@xx.dkwrote in message
news:e5**************@TK2MSFTNGP05.phx.gbl...
Hi,
I got a webservie that supply users with binary files based on a parameter
id. The method is void and I stream the file by:
HttpContext.Current.Response.ContentType = "application/xxx";
HttpContext.Current.Response.BinaryWrite(arrResult );
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
HttpContext.Current.Response.Close();
return;
If the parameter id is invalid or if something goes wrong I would like to
throw either 404 och 500 exception. I been tring to do this with the
following code but I will allways recieve a 500. How can I control the
output exception.
Oscar,
Well, you are passing back a 500. In what case do you hope to send back
a 404? I don't see anything that indicates that you want to send back a 404
response.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Oscar" <xx@xx.dkwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>I forgot to past some code....
HttpContext.Current.Response.StatusCode = 500;
throw new HttpException(500, "Error getting the file.\n\n" + e);
"Oscar" <xx@xx.dkwrote in message
news:e5**************@TK2MSFTNGP05.phx.gbl...
>Hi,
I got a webservie that supply users with binary files based on a parameter id. The method is void and I stream the file by:
HttpContext.Current.Response.ContentType = "application/xxx"; HttpContext.Current.Response.BinaryWrite(arrResul t); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); HttpContext.Current.Response.Close(); return;
If the parameter id is invalid or if something goes wrong I would like to throw either 404 och 500 exception. I been tring to do this with the following code but I will allways recieve a 500. How can I control the output exception.
Hi,
Sorry, I pasted the wrong code... it should of cource be:
HttpContext.Current.Response.StatusCode = 404;
throw new HttpException(404, "Error getting the file.\n\n" + e);
//Oscar
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:50**********************************@microsof t.com...
Oscar,
Well, you are passing back a 500. In what case do you hope to send
back a 404? I don't see anything that indicates that you want to send
back a 404 response.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Oscar" <xx@xx.dkwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>>I forgot to past some code....
HttpContext.Current.Response.StatusCode = 500; throw new HttpException(500, "Error getting the file.\n\n" + e); "Oscar" <xx@xx.dkwrote in message news:e5**************@TK2MSFTNGP05.phx.gbl...
>>Hi,
I got a webservie that supply users with binary files based on a parameter id. The method is void and I stream the file by:
HttpContext.Current.Response.ContentType = "application/xxx"; HttpContext.Current.Response.BinaryWrite(arrResu lt); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); HttpContext.Current.Response.Close(); return;
If the parameter id is invalid or if something goes wrong I would like to throw either 404 och 500 exception. I been tring to do this with the following code but I will allways recieve a 500. How can I control the output exception.
Oscar,
You shouldn't have to set the StatusCode if you are throwing the
HttpException. Are you finding that just throwing the exception is not
returning a 404 response?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Oscar" <xx@xx.dkwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,
Sorry, I pasted the wrong code... it should of cource be:
HttpContext.Current.Response.StatusCode = 404;
throw new HttpException(404, "Error getting the file.\n\n" + e);
//Oscar
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:50**********************************@microsof t.com...
>Oscar,
Well, you are passing back a 500. In what case do you hope to send back a 404? I don't see anything that indicates that you want to send back a 404 response.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Oscar" <xx@xx.dkwrote in message news:%2******************@TK2MSFTNGP04.phx.gbl. ..
>>>I forgot to past some code....
HttpContext.Current.Response.StatusCode = 500; throw new HttpException(500, "Error getting the file.\n\n" + e); "Oscar" <xx@xx.dkwrote in message news:e5**************@TK2MSFTNGP05.phx.gbl... Hi,
I got a webservie that supply users with binary files based on a parameter id. The method is void and I stream the file by:
HttpContext.Current.Response.ContentType = "application/xxx"; HttpContext.Current.Response.BinaryWrite(arrRes ult); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); HttpContext.Current.Response.Close(); return;
If the parameter id is invalid or if something goes wrong I would like to throw either 404 och 500 exception. I been tring to do this with the following code but I will allways recieve a 500. How can I control the output exception. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: guptatushar |
last post by:
I have a Webservice which calls another component sitting on different
machine
Machine A Machine B
Webservice ------------------->Component
Due to network problem when webservice calls component it kinds of
hung. I want to give a timeout to it and if within that timeout
period nothing comes back just throw exception. Any one can give me...
|
by: dan |
last post by:
hi ng.
i have a asp.net application which is client of an asp.net webservice.
now i want to configure a custom error page (in case the sewrvice throws an
exception)
that provides the soapexception detail property as text.
but when defined in web.config, the error page doesn't provide access to the
thrown exception anymore.
i think that i...
|
by: Andy |
last post by:
Make the story short, I have a VB.NET client interface calling .NET
webservice, written in VB.NET as well.
I am trying to make the client as thin as possible so I let the
webservice part to handle most of the things.
Currently I have a class called "Product" sitting my webserivce like
the following:
Code:
|
by: stephan querengaesser |
last post by:
hi ng,
i try to invoke a webservice-method with an filter-object, that
contains value types. if i don´t want to filter the return value of
the method, i have to pass a new instance of the filter-object without
setting any properties. but the value type-properties can´t be null
and the filter is set to 0 (int) or false (bool).
therefore i...
|
by: JeffL |
last post by:
I am trying to either redirect or throw an error through a webservice
that has been called through Microsoft webservice.htc element. What I
want to be able to do is if a user which no longer autheticated (Time
out has occured in forms authetication) that an error will return back
to the caller saying a time out has occured. I have tried...
| |
by: chris |
last post by:
hello, I can't seem to make this work:
VS2005
I have a simple program that uses a backgroundworker control to execute a
long process (webservice call)
if that webservice call fails, i want to raise an exception and display a
messagebox.
however no matter where i put the Try block to trap the error, it does not
work.
|
by: jaydev |
last post by:
Hello,
I want to create a header and footer control which will be used in
both the java and .net application. We are planning to create a
webservice for this in C#. I am familiar in creating a webservice , but
not sure how to create something compatible for java team (J2EE). Java
team needs to output of webservice in XHTML, CSS and javascript...
|
by: rn5a |
last post by:
I have created the following WebService named NConnect.asmx using which
I want an ASPX page to first authenticate a user & after successful
user validation, the ASPX page should display a few TextBoxes for users
to enter some data in those TextBoxes which will finally be inserted in
a SQL Server 2005 DB table:
<%@ WebService Language="VB"...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |