C# - Can Get WCF FaultException When Server Returns An HTTP 401

Jan 11, 2010

I have a WCF based test harness client for a set of web services. The test client allows me to see raw requests and responses going to and from the services. A Message Inspector endpoint behavior is used to "pick off" the raw requests and response messages and save them for later display in the UI.

This works great, except for the use case where invalid credentials are passed. The server returns an HTTP 401 along with a SOAP fault containing details of what happened. This hurts me in a couple ways:

On the client this shows up as a MessageSecurityException not a FaultException, so I can't get the details from the fault. This exception appears to prevent the AfterReceiveReply event handler on my message inspector from firing, so I have no access to the raw response.

Is there any way I can handle this case so that the SOAP fault comes through as a FaultException and allow my message inspector to handle responses regardless of the HTTP status code that is returned?

View 1 Replies


Similar Messages:

C# - Can Get The Message/response Body In WCF When Server Returns An HTTP 401

Jan 12, 2010

I have a WCF client test harness where I'm using a "client message inspector" endpoint behavior to "pick off" raw requests and response messages going to and from a service and save them for later display in the UI.

This works great, except for the use case where invalid credentials are passed (Basic Authentication). The server returns an HTTP 401 along with a SOAP fault in the body containing details of what happened. I have no control over the service, so this behavior cannot be changed.

Because the HTTP 401 is returned as a WebException, my message inspector never fires and I can't get to the raw response. This exception eventually gets to the UI in the form a MessageSecurityException.

Is there any way to suppress this so the message inspector's AfterReceiveReply still fires? or is there somewhere else I can access the entire raw response?

View 1 Replies

WCF / ASMX :: FaultException Was Unhandled By User Code - "Server Was Unable To Process Request"

Mar 3, 2011

I have created a web service that interacts with my DAL. It has the usual kind of methods, create, retrieve, update and delete. I have published this web service to our live Windows Server and I can see the web serice URL. The web service works on a few method calls but does not work specifically for one object. I am getting the following error: Fault Exception was unhandled by user code. "Server was unable to process request. ---> Data is Null. This method or property cannot be called on Null values."

To summarise: Web service is live, I can see it in my browser. Some method calls work. One specific one does not. I have verified that the method works (it is just calling a SQL stored proc that does return data).

View 2 Replies

Webservice Returns HTTP Error 500 After Deployment?

Nov 2, 2010

I have a webservice (ASMX) which I have tested locally using built-in VS web server. It works fine in the Dev environment, and there was no configuration of anything in IIS for this kind of webservice to work.

Today when I deployed my site on the live server, I got a 500 error when the webservice is being called. The website doesn't work, and unfortunately the client did not test this on staging (same server)

Here's the sample call to my service.

$.ajax({
type: "POST",
url: 'http://www.mydomain.com/services/someservice.asmx/MyMethod',
data: "someid=564",
dataType: "xml",
success: function(msg){
}

In Firebug, http://www.mydomain.com/services/someservice.asmx/MyMethod returns error 500 internal server.

I called the service using jQuery AJAX, the live server is Windows Server 2008 Standard.

View 1 Replies

Custom Error Page For 404 Returns 302 For Http Status

Nov 29, 2010

In my asp.net web site I have custom error pages defined as following in my web.config file.

<customErrors mode="On" defaultRedirect="~/defaulterror.htm" >
<error statusCode="404" redirect="~/404.htm" />

When file is not found it correctly display 404.htm page but the issue is when I do Fiddler trace it returns 302 as HTTP status code.This is a big issue for search engine page indexing due to this lot of broken links still have been indexed recently because of this in my web site. how can I prevent returning 302 as HTTP status code for file not found errors and return 404 for file not found errors.I am using asp.net 3.5.

View 3 Replies

HttpHandlers / Modules :: Securing A HTTP Handler That Returns Xml?

Apr 6, 2010

I have a HTTP handler that returns a GeoRSS feed (type of XML) when called. This handler is called from a javascript and the returning xml is consumed directly by a Virtual Earth (bing) map control on the same page. I am Encrypting/Decrypting URL parameters but any one can see the source html, copy the url and get access to the xml feed.Since the call is from javascript how can I prevent unauthorized access to the HTTP handler?

View 2 Replies

WCF / ASMX :: Webservice In Https Returns Undefined But Works On Http?

Jul 20, 2010

We have a problem regarding webservices when it runs in https. it say's that the service is undefined. BUT when we try it in http it runs okay...

View 1 Replies

Web Forms :: Redirecting To A Page At Server / Error Is Http 500 Or Http 403

Dec 2, 2010

I am having problem redirecting error when error is http 500 or http 403 locally running this site there is no problem it gets redirected to my errorpage.aspx. But when deployed at server, it does not get .tried putting try and catch in page_load and in global.asax and I have set Application_Error to redirect to that page and also set <customErrors defaultRedirect to that page also

error
statusCode="500"
redirect="/errors/errorpage.aspx?error=500"
/>

View 9 Replies

Security :: WebService Returns "The Request Failed With HTTP Status 401: Unauthorized"?

Jan 7, 2010

I wrote a web services with Windows authentication, when i consume this WS from my app inside my network all work great, but when I consume this WS outside my network the WS return "The request failed with HTTP status 401: Unauthorized"I'd try the URL in an explorer page and all works great.In my app I use this:

webservice.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

What alternatively can I use to get credential inside and outside of my net?

View 4 Replies

Server.TransferRequest Returns Blank Page On Specific Server?

Jun 17, 2010

I have a webapplication based on MonoRail, where we utilize the routing feature from MonoRail. On the first request after the application has started, the routing isn't initialized. To circumvent this, I have the following code in Application_OnError():

public virtual void Application_OnError()
{
if ( // identified as routing error )
Server.TransferRequest( Context.Request.RawUrl, false );
return;
}

Problem beeing that on our development server (which runs server 2008 R2, with IIS 7.5 and .NET 3.5) returns a blank page without headers, but on my workstation (which runs win7, IIS 7.5 and .NET 3.5) it works fine.

What could be the cause of this? If the code in Application_OnError() throws an exception, what would be the expected output?

I have verified the following:

The access-log shows one entry, I'm not sure if a TransferRequest would show up as a second entry when invoked successfullyThe application actually do some work according to my internal logs, and it doesn't die since a subsequent requests works flawlessly (because routing will be active)

View 4 Replies

SQL Server :: SCOPE_IDENTITY() Always Returns 0?

Mar 3, 2011

I am trying to return the identity value of a inserted record for the first time in ASP.NET but it always returns 0, I can see in the database that a record is being inserted and the identity value is not 0.

Stored Proc:

[Code]....

Code Behind:

[Code]....

View 8 Replies

SQL Server :: Scope_Identity() Always Returns 0 And Not The Identity?

Oct 21, 2010

I have a Stored Proceedure which DID return the Scope_Identity when this was executed in SQLServer 2000.

Now I am porting this over to SQLServer 2008, and this always returns 0, and not the Scope_Identity which it should.

Here is the Stored Proceedure which will pass null for the parameter @pProjId for an insert:

[Code]....

Here is the script which creates the hip_Project Table:

[Code]....

What do I need to change for SQLServer 2008?

Again, this executed fine in SQLServer 2000 and always returned the Scope_Identity as expected. This problem has come up with other stored proceedures as well for which I need the Scope_Identity returned.

View 3 Replies

SQL Server :: SqlDataAdapter Update Returns 0 Records?

Jan 25, 2011

using ASP.NET 2.0 SqlDataAdapter update returns 0 records. I have a simple application that stores Passenger's ticket info in a sql database.

when a user clicks "Create Reservation" I add a Passenger Information (name, destination, PNR) to dataset
and save dataset in ViewState.

Then when user clicks update, I pull the dataset from viewState and try to update database. The update is returning 0. what i am doing incorrectly?

protected void btn_CreateReservation_Click(object sender, EventArgs e)
{
DataRow dr ;
dr = dt.NewRow();
dr["Name"] = txtBox_Name.Text; dr["Destination"] = txtBox_Destination.Text;
dr["PNR"] = Convert.ToInt32(txtbox_PNR.Text); dt.Rows.Add(dr);
dt.AcceptChanges();
ViewState["MyTable"] = dsPassengers;

[Code]....

View 1 Replies

Retrieving Message Body When Server Returns 500 Error

Oct 12, 2010

I have a routine that submits a SOAP request using HttpWebRequest and WebResponse. If the SOAP Request fails the server sends back HTTP/1.1 500 Internal Server Error. When I trap the error I have yet to find a way to view the body of the reply which contains the fault code. Is there a way to retrieve the message body when the server returns a 500 internal Server Error? In body of the reply which I am not able to retrieve.
faultstring xml:lang="en-US" Specified argument was out of the range of valid values.

View 1 Replies

SQL Server :: Joins - Returns A Row When There Is Matching Table In Both Tables

Jan 29, 2011

Inner Join:- Returns a row when there is matching table in both tables. we can use comparison operator like =,<,>,<>

I created two tables

TableA


ID OID Type

1 1 A
2 6 B
3 7 C
4 10 D

TableB

ID Value
1 10
2 30
3 40
5 60
6 70

Basic Inner Join select Type From TableB as a inner join TableA as b on a.ID=b.OID Result Type

A
B

If i want only the type which has not match in tableB then i can use not in subquery i get the result if i m using select Type From TableB as a inner join TableA as b on a.ID<>b.OID then i get

Type
A
A
A
A
B
B
B
B
C
C
C
C
C
D
D
D
D
D

18 rows affetected i m suprise

View 3 Replies

SQL Server :: Update Multiple Records - Subquery Returns More Than 1 Row

Jan 5, 2011

I have a table line (ID, LineNo, LineName) having values as :

1, 1, <blank>
2, 2, <blank>
3, 3, <blank>

ID is PK with Auto-Increment and LinNo(I am manually incrementing through ASP.Net Page while record insertion) Now i have to write a query such that it updates LineName column from line table which is blank(as shown above) with values from table linet(linenamet) having values as :

a
b
c

My trial query is :
update line set LineName = (select linenamet from linet);

It gives ERROR as : Subquery returns more than 1 row
Expected Result : After Updation it should show line table as :
1, 1, a
2, 2, b
3, 3, c

View 8 Replies

.NET MVC With SQL Server Backend Returns Old Data When Query Is Executed?

Jun 12, 2010

My ASP.NET MVC web app has a weird issue. In VS debugging mode it works as expected, but when I publish it to dedicated web server (windows 2003, IIS6) a sql query returns previous data even though underlying data was already updated through the same connection. It looks like as if a query returns cached data. What might be the problem?

View 2 Replies

Mock Server.HtmlEncode - Returns Null Reference?

Nov 16, 2010

I'm trying to mock Server.HtmlEncode(), but I keep having a null reference exception.I'm pretty new to the Moq framework, here is my code:

var context = new Mock<HttpContextBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
server.Setup(svr => svr.HtmlEncode(It.IsAny<string>())).Returns((string s) => s);
context.Setup(ctx => ctx.Request).Returns(request.Object);
context.Setup(ctx => ctx.Response).Returns(response.Object);
context.Setup(ctx => ctx.Session).Returns(session.Object);
context.Setup(ctx => ctx.Server).Returns(server.Object);

I've also tried the following:

context.Setup(ctx => ctx.Server.HtmlEncode(It.IsAny<string>())).Returns((string s) => s);

I've found a solution but it seems an outdated solution as expect is replaced with setup.

View 2 Replies

VS 2005 Code Returns The Process ID Correctly With Virtual Server?

Jan 29, 2010

I am using this code to get th ProcessID of newly Created Excel.

Code:
Imports Microsoft.VisualBasic
Imports Microsoft.Office.Interop
Public Class Class1
[code]....

This code returns the Process ID Correctly with Virtual Server. Now I deployed it using a Website, and the ProcessID is 0

View 7 Replies

SQL Server :: Update Statement Not Updating Records And Returns No Errors?

Sep 16, 2010

I am running an Update statement against an SQL database on server 2008. The update runs but does not update the record, but returns no errors.The database is part of a commercial help desk package called TrackIt 8.5 which was just a fresh install on a new web server and a new sql server. The update is running from a web form we use to automatically create active directory accounts. After the account is created the web form closes out the work order in the Trackit db. This was working fine when the system was running on Server 2003 and SQL server 2005. Running Trackit version 7.02.The login use to access the database has full permissions to read and write to the database, just as it did on the old server which never had an issue updating. Odd thing is, if I log onto the SQL server and make a change to any single field in that record. I can then run the web form and it updates the record normally.

View 3 Replies

ASMX Service Works On Development Server Returns 404 When Deployed To IIS 7.5?

Mar 24, 2011

I have a web application in ASP.NET 4.0. I've added an asmx service, primarily as a source for the autocomplete extender's lookup values.

When I debug on my machine locally, everything works fine. However, when I deploy the web application to IIS 7.5, I get a HTTP 404 response when trying to send data to the service.

I am able to browse to the service definition, see the available operations. Tellingly, however, when I use the test pages to test the service using POST, I receive an HTTP 404 again.

I'm not sure what is going on. I did create the asmx file within my web application and it is deployed in the virtual directory of my otherwise working production application. Is there an issue with the .asmx file being deployed in the same virtual directory, perhaps?

View 1 Replies

HTML - Runat=server Removes Carriage Returns From Head Tag?

Jul 2, 2010

I'm new to .net, and I've noticed that when viewing my HTML source code generated by a .net application the carriage returns are removed from the head tag when it has runat="server" attribute on it.

I remove the runat="server" and the returns... return.

This really looks nasty when you have a few javascript and css files in your header because it ends up making the entire contents of the head tag 1 big line.

Just wondering if there's a way to control this or tell .net through configuration not to mangle the output?

View 4 Replies

SQL Server :: Create A Stored Procedure That Returns Data From 2 Odbcs?

Nov 5, 2010

Using vs.net 2005 and sql server 2005.

Hope this makes sense: I need to create a stored procedure that I am going to use as a datasource for a crystal report in vs.net.

The issue is that the data is stored in 2 different kinds of databases, one is sql server and the other is plb files.

I have an odbc connections created for each separately however I need to make one query that joins data fields from both the sql server db tables and the plb db, how do I do this in one query that I will use in a stored procedure?

View 3 Replies

SQL Server :: Select Query That Returns Records By Date Today

Sep 22, 2010

In my data table i have a Date Column with of type DateTime.

In my sql select query, I want to return all records where the date is today.

View 8 Replies

Button That Performs A Server-side Action And Returns A File To Download?

Jul 28, 2010

I have an ASP.NET page (using ASP.NET AJAX and the Telerik RAD components) that provides a data table and an option to download data in CSV format.I have a requirement that a single button allow the user to download a data set. I have a system set up that's nearly working for me based off the solution in
http://stackoverflow.com/questions/104601/asp-net-response-redirect-to-new-window

<asp:Button ID="ExportCsvButton" runat="server" Text="Download to CSV/Excel"
byte[] csvBytes = someLongOperation();
Session[EXPORTED_SESSION_KEY] = csvBytes;
Response.Redirect("myexportpage.aspx", true);
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AppendHeader("content-disposition", "attachment; filename=" + "file.csv");
Response.ContentType = "text/csv";
Response.AddHeader("Pragma", "public");
Response.BinaryWrite(Session[OtherPage.EXPORTED_SESSION_KEY] as byte[]);
Response.Flush();
Response.End();
}


This actually works quite well. When I click the 'Export to CSV' button, the page's UpdateProgress kicks in and my loading overlay appears (it's a CSS div that covers the window when visible). This can take some time depending on the data set (potentially several minutes), at which point I'm getting a window popup with my file.

View 1 Replies







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