.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Passing variables in a post request

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

Hi 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 ).

Any ideas how to do this ? thanks


edit : typo corrected

View Complete Post

More Related Resource Links

Session or Request in class without passing as param

I'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 namespace xx { public class ContextPT { public static string GetSession(System.Web.SessionState.HttpSessionState inSession) { StringBuilder sb = new StringBuilder(1000); string nameType; string value; foreach (string s in inSession.Keys) { nameType = s + " " + inSession[s].GetType().ToString(); value = inSession[s].ToString(); sb.AppendLine(nameType + ": " + value); // dataRow(new string[] {nameType, value}); } return sb.ToString(); } } } somewhere else this.lContext.Text = ContextPT.GetSession(Session); 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. 

AJAX Form POST Request to a DLL Problem

I am using AJAX javascript for POSTING a complete HTML form to the server which is an external dll on a different server and displaying the response. The server-response is displayed in a "div" . basically i need to show a poll in a .aspx page which is basic a question with 3 options & a button. Now on click of submit button i need to post the data to a dll & show the result from the dll itself. Any idea how to do this? is it possible..any code???

Passing checkboxlist variables and returning one row at a time

I am designing a page for my students to practice their Latin vocabulary.  I am having two problems with the design: 1) working with checkboxes, and 2) display one returned row at a time. 1) First, students select from CheckListBox1 those parts of speech (nouns, verbs, adjectives, etc.) they want to review, and then they click Button1 ("Submit"), which fires off a SELECT statement against a table named CoreVocab in a SQLEXPRESS database.  How do I pass each selected part of speech from CheckListBox1 as a variable into the WHERE statement when the user clicks Button1? Do I place this code in the Button1_Click on the .cs page? 2)  Ideally, the table returns the first row and Button1 changes to "Next," which the student then clicks to see the next Latin word.  How do I get the Repeater table to show only one row at time until the Next button is clicked? And how do I get the same button to executed two functions (fire off the SELECT statement and then show the next row)?  For what it's worth, I'm using the SqlDataReader command, since data will only be retrieved, not modified. Thanks. I'm new at this.  But I really need to do something for my suffering students. Oliphant

WCF HTTP POST - The remote server returned an error: (400) Bad Request. - URGENT

client & sever code below-------------------------------------------- [ServiceContract(Namespace = "http://test.mydomain.com")] public interface IMyService{[WebInvoke(UriTemplate = "", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")] Stream SaveXML(Stream input); } ----------------------[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(Namespace = "http://test.mydomain.com")] public class MyService : IMyService{  public Stream SaveXML(Stream input)   {              StreamReader streamReader = new StreamReader(input);       string rawString = streamReader.ReadToEnd();       streamReader.Dispose();        // here need to save the input stream to xml format file          //       Encoding encoding = Encoding.GetEncoding("ISO-8859-1");       WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";         byte[] returnBytes = encoding.GetBytes(rawString);       return new MemoryStream(returnBytes);   } } --------------------------------------------------Client Code         string postData = GetXmlString("d:\\text.xml"); // user function        WebRequest request = WebRequest.Create("http://test.mydomain.com/myservice.svc");        request.Method = "POST";        byte[] byteArray = Encoding.UTF8.GetBytes(p

wcf 4 rest service accepts xml and json posts but get 400 bad request on form post


Using the rest 4 template.  I have a POST method defined, with an object as a parameter.  REST 4 does a great job of automatically mapping both xml and json posts to the method.  I tested this using an HttpClient test application to build and post xml content and then json content.  All data gets correctly mapped to the corresponding properties in my entity. 

I want to also support a standard form post to the method but am having problems! 

I'd like the same method already accepting and converting both xml and json to also work correctly for a form post.  I figured it would "just work" but no.

I am testing this by creating an HttpUrlEncoded form in the test client, adding form name/value pairs that match what the method is expecting, and trying to post it.

However I get a 400 Bad Request.  Here's some example code that is returning a 400 bad request:

Really straightforward but fails.  Ideas why? 


      var client = new HttpClient();

      HttpUrlEncodedForm form = new HttpUrlEncodedForm();
      form.Add("Id", "99"<

IIS 6.0 not passing request to asp.net



 I have my asp.net mvc site set up with wildcard mapping. for requests that dont have a matching routing, IIS6.0 is showing the default 404 error message even though i have customerror message configured in the web.config. 

Any ideas?

Passing in the variables for 'Between'


I'm using SQL 2008 and VS 2010.

I have a sproc that ends with:

WHERE RowNumber Between 1 and 1;

(I only have two records in it right now)

What does everyone use to pass in the variables from a webpage, without any datacontrol, in place of the 1's?

I've used cookies and session variables, but is there a better way during postbacks to fill the gridview?

HTTP POST request and encoded string



I have to do a simple HTTP POST request by key/value pairs and receive a XML file with a session key. I made it work, but there's something strange about it - when session key includes character '&', then it return encoded like '&amp;'. After that my application needs to send that session key to server every time I make a query. When session key includes '&', then query won't work, because server side is expecting correct (not encoded) session key. Does somebody knows how to fix this problem? My HTTP POST Content-type is "application/x-www-form-urlencoded".

Data Paging and passing variables to text box




Please help I am having troubles making the code run. I have a web page with a gridview and a checkbox. I would like the button when selected to pass the category id. I have managed to get it work without paging. Once the paging kicks in see below, I am unable to run the code. Please see below.






In the design: ASPX


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

Passing ViewModel (containing request parameters) across controllers


Pls. pardon my ignorance. I have few questions based on following scenario:

I have a LoginController with following methods:

 public ActionResult Login()
        return View();

    public ActionResult Login(UserObject user)
     Calling Besiness Service to Validate User againts DB (Using Repository)... 

        if (success)
            return RedirectToAction("Search", "Search");
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
        return View(user);

After successful login, I have to present a Search screen. I have a SearchController with following methods:


Pre-deployment & post-deployment variables


Hi guys. Now, in VS pre-build and post-build we can insert variables such as $(OutDir), $(TargetDir), etc. Can we do that in pre-deploy and post-deploy to get the Site URL they're deploying to? Something like $(SiteUrl)? If I hardcode this URL and check it in to subversion then it's going to mess up the VS deployment for everyone else on the team who develop on their own SP Foundation instance.

Any ideas?

Passing service end point credential in request

I need to call a service end point protected behind a security gateway (non-ms technology from IBM), so there are credentials for the gateway and credentials for the service end points, how can I pass these two sets of credential in the service call?

Error when passing variables

where end_tran_date = '+ @Today +'
order by end_tran_date asc'
print (@sql)

Error Messsage:


Msg 241, Level 16, State 1, Line 10

Conversion failed when converting date and/or time from character string.


Temporary tables in SQL Server vs. table variables

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables.



Dear gentlemen and ladies of the Microsoft Dynamic Data Team,

Mr. Steve Naughton says (and I hope so) that there might be chances that you read the posts published in this forum: I really hope so.

If that were the case then I am formally requesting to you in providing a "real answer" to my question:

I want to customize a dynamic data page (the details one) so I can have access to the data it has been already gathered from the end user UI (details.aspx) and use it to pass this same data to the following controls/pages that I am going to display next time to the end user.

For instance:

I have a screen with different types of data in it: texts, numbers, dates, check boxes, radio buttons and dropdownlists that has been filled with data by the end user. I want now to reset all fields exept the dropdownlist of which I'd like to keep the previously chosen values(the very same thing you do between dropdownlist of List.aspx ad Details.aspx). Even with FoxPro I could do that because data and controls were available there. It was as simple as setting carrying on to true.


I have found my

view state vs request parameters


If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


Unique ID throughout entire request



I am hoping somene here could advise me on a better solution to my present problem.  First a little background information on the application. 

I have a web application using the 3.5 framework.  The structure of this application is as follows: UI -> WebService   -> Business Layer -> DataAccess Layer.   What I want to accomplish is for every request (click on a link or button) have a unique identifer that follows this request through its entire lifecycle.  This unique identifer can be accessible anywhere within this request.  We use Response.Redirects which could easily be changed to Server.Transfers (although I do not want to do that) but  the problem lies with the web service calls.  Currently, a GUID is set in the ApplicationRequest.  This GUID checks for a guid value in the RawURL and if so, assigns this value to a HttpContext Item.  If not, HttpContext.Items gets a new one created.  However, this idea is wrong and will need to be revisisted.  The bigger problem is with the web service calls.  Without changing every web service method signature, and every call for that matter, is there a way of getting this GUID there.  I created a web method in every web service so that each time I instantiate a web service object in the UI, before calling any

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend