WCF / ASMX :: Passing Custom Headers To A WCF Request
Feb 10, 2011I have the following code:
[Code]....
And on the server I do the following:
[Code]....And it's always null as if the header was never added to the request.
I have the following code:
[Code]....
And on the server I do the following:
[Code]....And it's always null as if the header was never added to the request.
explain to me the concept of Request.Headers and Response.Headers in ASP.NET? Under what scenarios you use Request.Headers and Response.Headers?
View 1 RepliesI have a webservice which works 100% fine on my developer machine. Where Web Service is installed on LOCALHOST on my developer machine,Then i went to my servers, I installed webservice on one server and map it with the server where the website is hosted, Then i tried accessing this service using BROWSER from my web server, it worked fine, That means the mapping was done perfect.Then i run my program on web server (website). It worked fine on page1, then on page2, but when i did the same and call same function on page3, It popped me any error of
View 4 RepliesOn my page I have a dropdown for country.
On my asmx service I want to get the value of the dropdownlist to filter the next input which will be state/providence.
My code on the asmx:
[Code]....
I want to add another clause to the WHERE statement to restrict Country = @Country so I will need to get that value to the web service.
A customer reported that our asmx web service is continually increasing in memory (mem usage as well as private bytes). We are able to reproduce the problem in our lab with Windows 2003 Server SP2 (fully patched) on some of the machines. The customer is using Windows 2008.
We created a Hello World web service targeting the 2.0 framework built under VS2005 SP1 and a test client that continues to call it. The memory increases steadily - approximately 40K per client request. If the test app is paused, the memory remains the same. When it is closed, the memory drops. Explicit calling of GC.Collect does not drop the memory.
We have run the memory profiler on the service and the leak is all native memory. We have uninstalled/re-installed the Framework on one of the machines but no difference. To our knowledge all of the security and IIS settings are not modified. We have compared app pool, default web site and virtual directory properties to machines that have no problem and they are identical.
I am facing an issue while calling a web request thru my code. I have searched a lot on number of sites but did not get any solution.
Here is the code which I am using:
[Code]....
In IIS 7.0 integrated mode after deleting all headers with Response.ClearHeaders() IIS would add some other headers like Server and X-Powered-By which reveals good information to hackers. How can I stop this behavior (consider I still need to add my custom headers) ?
View 2 RepliesI've created some custom headers for my emails. I've used a breakpoint to see that they are being added to the collection correctly. I don't understand how to access these from the email that's generated though. I'm currently dropping the emails into a pickup directory on my local machine and viewing them with Windows Mail. I have "view all" headers checked in Windows mail but still don't see them when I open my emails in the pick up directory.
how to access the headers that I added? Below is an example of how I did it. I'm hoping to add things like name, address, phone... etc, and then have them visible in the email.
Is this even the correct use of custom headers?
[Code]....
In the web app (C#, ASP.NET) I am working on at the moment, the value in Request.Headers["Referer"] can determine things like custom style. I have created a custom page with a drop down menu to test this functionality. So when the selected index changes, the value selected should be set in the Request.Headers["Referer"] then will be redirected (Response.Redirect), the receiving page will then pick up the value in Request.Headers["Referer"] and adjust the styling accordingly. However I haven't been able to set value for Request.Headers["Referer"]. Is it possible at all?
Website 1 sets the value in Request.Headers["Referer"], e.g. www.xyz.com and before doing Response.Redirect to www.website2.com
Website 2 picks up value in Request.Headers["Referer"], in this case www.xyz.com and do what it needs to do, i.e. styling etc.
I have one IIS entry with AppPool integrated mode. There are 5 or more host headers assigned. The application pulls data based on the host name from Request.Url.Host. When I have 2 or more sites open at the same time the value of the Request.Url.Host is the same across all the sites. About every 30 seconds it resets itself to the correct value from the last request and shows that value on the other sites. So ultimately the sites are loading the same data. The value in the HOST server variable is incorrect as well.
View 1 RepliesI have never work with a repeater and after a lot of research I got to the conclusion that this is the control I need to use for what I have to do. I need display data but I will need 2 headers and after some sort of amount of records the headers will repeat again. In this page you will find an example of what I'm trying to do http://ratings.fide.com/view_source.phtml?code=45276 I don't know if a repeater is the right control but i thin it is.
View 3 RepliesIn C#, How do you pass the Session[] and Request[] objects to a method?I would like to use a method to parse out Session and Request paramaters for a .aspx page to reduce the size of my Page_Load method. I am passing quite a few variables, and need to support both POSTand GET methods. For most calls, not all variables are present, so I have to test every variable multiple ways, and the code gets long...This is what I am trying to do, but I can't seem to properly identify the Session and Request paramaters (this code will not compile, because the arrays are indexed by number)
static string getParam(
System.Web.SessionState.HttpSessionState[] Session,
System.Web.HttpRequest[] Request,
string id)
[code]...
I'm trying to develop a Web application that sends requests it recieves to another server. Basically, my application will work like a proxy sending requests and responses to client and real server. I'm using HttpHandlers to capture all requests coming to server and using a class implemented from IHttpHandler, I create another request to my target server.
So far, I tried:
[Code]....
which got me the first page I request, for example when I request login page, I see it, but I can't see css or images(basically because it writes css and image files to page with context.Response.Write) also, since I did not get server variables I can not log in to my server, I keep reloading login page when I click login button.Then I tried changing the Host header of the first request I got thinking I could do a request with same request headers.
[Code]....
And got the error saying "Operation is not supported on this platform".
I need to pass variables from a script to another with POST , Not GET , and without a form ( i must do it literally )
there is the Response.AddHeader(name,value) function
then the response.redirect
But then i think the variable field has no name ( after the content lenght header ).
I'm building a greasemonkey script to make posting to craigslist a lot easier for our clients.
Basically the flow is this:
User logs into our system (established authentication cookies with asp.net)User navigates to a section on our site called "CraigsList". If they have the greasemonkey script installed it automatically opens up craigslist in a new tab.
The greasemonkey script then does a request back to our site at [URL] to retrieve a list of available items to be posted to craigslist.
This is where it fails because the request to [URL] is not including any of the authentication cookies. I'm not sure if it doesn't include the cookies because the request originates from [URL] and not [URL] or what. I know it's an authentication issue because looking at it in fiddler it returns a 302 and redirects to the login page.
Here is my request:
[code]....
I have the .asmx web service written in .NET 2.0 .This service uses the WSE 3.0 .for authentication.This service checks the request header (header contains teh Uer name and pwd) and validate against the database.after validating gives cal to the actual method.everything works fine in frtamework 2.0.Now i have created the project.Added the proxy of the service into the project(proxy is created using svcutil.exe)but I am not able to pass the user credentials to the service.//Comment: Set the Username Token Information.'
View 4 RepliesI'd like to be able to reference the asp.net objects Session, Request, from a procedure without passing them in as parameters all the time. Is there a way to do this. For example, now I have
[Code]....
I'd like to call it like this "ContextPT.GetSession()" and have GetSession know how to find the Session object. I know this does not seem like a big deal in this case, but I have reasons.
tried so many different things but havent got past this seemingly trivial problem. I created a WCF service application from visual studio 2010 WCF templates. it generated the IService.cs and Service1.svc files and generated the web.config
i created a website in IIS 7 on windows 2008, and pointed it to the app folder. when i go to [URL] via web browser, i get a message indicating service is running and suggests using svcutil etc etc., but when i go to [URL] the web browser says 400 bad request. this is without changing anything from what VS generated. the operation contract looks like
[Code]....
Update: forgot to mention i even tried decorating the operation with WebGet attribute with UriTemplate parameter, without luck.
[Code]....Web Service Getting Request
[Code]....
I'm running a WebMethod when a user clicks a link and I want the service method to have access to the clients SessionID but when I try to initialise a new string it returns a null value.
So to clarify(an example):
[WebMethod]
public string myMethod()
{
string s = Session.SessionID.ToString();
//rest of method here...
}
string s is returning null value. The code works fine on a postback and the method works without SessionID but I really want/need to be able to use a callback and need to be able to use the SessionID
I have some javascript that calls different web methods likeso
[Code]....
That's all fine & dandy but now i need to call a web method and pass it a file!
This is my current JS code
[Code]....
Now it jumps straight away to OnUploadFailed without ever going to the webmethod
I'm consuming an external web service (yahoo adverts), and what I need is capture the SOAP XML request I'm sending and response I'm getting.
I tried using Fiddler, but wasn't able to capture the request. how to do this?
I created a WCF. The web.config is as follows,
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
The following can be seen in the service.svc file,
class AppServiceHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
return new WebServiceHost2(serviceType, true, baseAddresses);
}
}
This is the method in the service.svc.cs,
[WebHelp(Comment="Sample description for GetData")]
[WebGet(UriTemplate="/GetData/param1/{i}/param2/{s}")]
[OperationContract]
public SampleResponseBody GetData(string i, string s)
{
// TODO: Change the sample implementation here
// if (i < 0) throw new WebProtocolException(HttpStatusCode.BadRequest, "param1 cannot be negative", null);
return new SampleResponseBody()
{
Value = String.Format("Sample GetData response: '{0}', '{1}'", i, s)
};
}
The following is the webservice url. It returns data if it's run through the asp.net engine but throws bad request when run from IIS. I added the following entry in the web.config but no use. it still fails.
<httpRuntime maxRequestLength="1500000" executionTimeout="180"/>
[URL]-499,500~~~/param2/621100,621600,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,621100,621600,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,621100,621600,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,,622100,611500,611600,611700,561300,611100,611200,611300,611400,622200,622300,623100,611100,611200,611300,611400,622200,622300,623100,611100,611200,611300,611400,622200,622300,623100,611100,611200,611300,611400,622200,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,622300,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,623100,611100,611200,611300,611400,622200,622300,623100,623100,623100,611100,611200,611300,611400,622200,622300,623100
Am consuming a web service for example Calculator
Calculator CALC = new Calculator();
int a = CALC.Add("23","27");
and result will be stored in a;
Please help me to encrypt this request using the X509 certificate. Am having a certificate with public key and with subject "My Calculator"and also decrypt the result with the private key "abcdef" and with subject "My Response"
I have this wsdl file and here is how the requets look like.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<Request xmlns=http://www.sometest.com/ttt>
<UserDetails xmlns="">
<UserName>username</UserName>
<PassWord>password</PassWord>
<AsiakkaanViite/>
</UserDetails>
<DestDetails xmlns="">
<SearchNameAndAddress>
<Name>company name</Name>
</SearchNameAndAddress>
</DestDetails>
</Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
how i can code this in c# or send the request?