.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

Requires action parameters as POST

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

hi guys, may be a simple question, but I can't find the answer.

For various reasons, I want my controller's actions to only be accessed via post. Thats easy, simply use [AcceptVerbs(HttpVerbs.Post)] and done.

Now, I'd like to force the requests to use post for the parameters. With [AcceptVerbs(HttpVerbs.Post)], as long as the request is done as post, the parameters can still be sent via the query string. 

Is there a way to force them to come from post variables? (ASP.NET MVC 2)


View Complete Post

More Related Resource Links

Form Action Button to pass parameters through URL and how to fill a NewForm with them

Hi I'm trying to solve a bigger problem we have in babysteps, and I guess after days of searching and trying I simply need to ask for help. The big picture is, that we're trying to put a Form Action Button (via Sharepoint Designer 2007) above a custom DataForm DispForm.aspx which is supposed to navigate to a NewForm.aspx where the Title Field is supposed to be prefilled with a parameter from the DispForm and the user should be able to add information to the item before it is saved. I found several explanations from people on the internet, but nothing really worked. The first babystep would be to get the parameter through the button into the url of the new item.   < input type = "button" value = "Zugriff Beantragen" name = "btnFormAction0" onclick = "javascript: {ddwrt:GenFireServerEvent('__redirect={../Zugriff Beantragen 2/NewForm2.aspx?test={ItemID}')}" />   That's the code for my button. Somebody wrote that should definitely work because SharePoint is able to replace {ItemID} with the actual ID of the item. Well.... it kind of doesn't. What I get as the end of the new URL is exactly "...?test={ItemID}"   I tried with different names for the ID, I added an @ before those ... no change. I read somewhere about javascript.functionName() which should work with all parameters of the item, but

Using HttpWebRequest to send POST data with parameters and a file

I have a form that has the following<form action="http://site" enctype="multipart/form-data" method="post"> <input type="hidden" name="action" value="the action" /> <input type="hidden" name="apiKey" value="key here" /> <input type="hidden" name="name" value="racing" /> <input type="hidden" name="title" value="Race Cars" /> <input type="hidden" name="signature" value="sig here" /> <input type="file" name="file" /> <input type="submit" name="_upload" value="Upload" /> </form>I know its not .net controls.. but hat doesn't matter for now, what I need to do is post this form with all it's data, but entirely in code.I have found this post: http://www.developmentnow.com/g/36_2005_3_0_0_300351/Using-HttpWebRequest-to-send-POST-data.htm this describes how to do it but I am not getting it.I will have a file upload on my page and a textbox for name and title, but the rest are generated in code.I know it's a long shot, but can anyone give me an example of exactly how I would do it for  my scenario? I have been at it all day and I am struggling! I keep getting bad gateway errors when

SharePoint Designer: Sending parameters with "Navigate to Page" form action

I want to create a custom button in my SharePoint form that uses Form Actions that commit the changes in the fields and then navigate to a designated page.  This works very well.

Then I want to send a parameter with the URL, for example: http://.../customform.aspx?ID={@ID}.  SharePoint Designer offers this option, but I have not been able to make it work.  Every time it just sends the literal {@ID} instead of it's content.

Has anyone solved this issue?

jQuery post to an action method



I hope this is the right section to post this, as it does seem to be an MVC related issue. I'm trying to use the jQuery.post() function to post an object to an action method, but for some reason the nested objects aren't initialised properly when they're received by the action method.

Here's my javascript code:

var data = {
    Id: 10,
    User: {
        Id: 5
$.post("/Home/SaveCompany", data, function (data) {

And my action method:

public ActionResult SaveCompany(Company company)
    if (company.Id > 0) {
    } else {
    return Json(new { id = company.Id });

company.Id has a value of 10, but company.User.Id is 0. Any ideas what I'm doing wrong? I've not named any properties incorrectly, by the way.


Action methods with several parameters



I have a few action methods that accept several parameters and return a view model object, and am trying to decide the best way to refactor this. I *could* just make the methods take an instance of the view model object, which I pass to my service layer that gives me back an updated instance. But would it be better to create a separate DTO object that just defines the parameters of the action method, which I can pass to my service layer and get back a view model?

As an aside, is it normal practice to have the view models defined in the service layer?


IE8 POST Parameters to SSRS 2008 Not Working


I am not a web expert nor a programming expert.  I know a fair amount about SSRS.  With that being said, we are having an issue with our internal architecture.  We have some custom search forms set up for users to edit/enter parameters.  These search forms then POST the parameters to the proper report in a new window.

This has always worked without a problem.  However, now that we are starting to bring up machines that are Win 7 IE8, we are seeing issues.  With an IE8 machine, the POST no longer works.

It would be great if someone was able to give me their opinion on the matter.  While this could be an IE8 issue, this will not happen if I post to any other site besides SSRS.  Every other site we have tested seems to work just fine - this is why I am starting this thread here.   For some reason, when it comes to SSRS, IE8 does not want to POST on the first attempt.

Here is our search form simplified for this example:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="onemoretest.aspx.cs" Inherits="GetAndPost.onemoretest" %>


ViewModel in post action is null

I'm having a problem that my ViewModel in a Create Action Post is not filled. It is always null...
I've used ViewModels already for viewing pages but not for a create action.
Say I have the following ViewModel:
public class TrouserCreateViewModel
        public Trouser Trouser { get; set; }
        public int Hallo { get; set; }
The Trouser object has the properties Name, Size and Length and is an entity in my EF4.0.
If I create a view with only a textbox for the integer Hallo everything works fine. In the post I get the TrouserCreateViewModel back and the int Hallo property is filled with the number that is filled in the textbox.
But if I create another textbox:
@Html.EditorFor(model => model.Trouser.Name)
The ViewModel is posted but the properties in the ViewModel are null. Even the Hello property is null then.
If I use the code:
[Bind(Prefix = "Trouser")]Trouser resource
then the Name property is filled. I don't know what the Bind does and why this works but can somebody explain why my regular properties for my ViewModel are null???
public ActionResult Create(TrouserCreateViewModel 

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

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?


Post back puzzle


Hi, I have a website where the user makes a selection from a combo box and it then fills a couple text boxes with text based upon the selection. I'm sure as you know it could take a second for the text to appear in the text box due to the post back. I know there is no way to make it instantanious, so what I would like to do it fill the text box with somthing like "Loading Info..." so the user does not type in it while the information is loading.

If you would like to see what I mean please go to this page: www.epiclinks.com/create.aspx and mess around with the combo boxes and You'll see what I mean.

What I would like to do is have it do a post back to write "Loading Info..." and then do another post back to fill it in based upon their selection. How would I do this?

I'm up for anything, so if you have a better solution than that please let me know.


pass value from textbox to action, formcollection best way here?


Hi I'm building a e-commerce store and on quantity of product I'm going with a textbox. I thought I would ask how would you do this? a viewmodel to use a strongly typed textbox or just get the value of the textbox from the formscollection passed in to the action?

Thanks for any input

Looking for ASP.Net JQuery Post Sample


Hi, iam looking for a JQuery Post Sample, without reload of the current Page. I want on a webform enter a search text, onclick on the submit button i want get (webservice?) back clean html code that will be shown in a div tag
i found something like

<form id="formsearch" onsubmit="jQuery.ajax({type:'POST',dataType:'html',data:jQuery(this).serialize(),success:
function(data, textStatus){jQuery('#ajaxcontent').html(data);},beforeSend:function(XMLHttpRequest){$('#indicatorSearch').
show();},complete:function(XMLHttpRequest, textStatus){$('#indicatorSearch').hide();},
url:'/Search'}); return false;" action="/Search" method="post">

but how is the source asp.net (or webservice) build up?

can you give me some samples, how i can realize that with asp.net


FormView -- Parameters and asp:Table


I've already solved this problem to my satisfaction, I just want to know WHY it works this way.

I have a FormView control bound to an ObjectDataSource.  Let's say our data source is a hypothetical table with three columns:  id, name, age.  Why is it that when I use the <asp:Table> element inside of the FormView, the parameter values are not set, but when I use the standard <table> tag, it works fine?

This seems like a .NET problem to me.  I expect the <asp:Table> element to work in the same way as <table> because they are, for all intents and purposes, the same thing.  Am I missing something?

linqdatasource parameters question



I'm currently getting to know the linqdatasource control. What would happen if several WHERE parameters are added to the linqdatasource control declaritively in the aspx page but no WHERE clause is defined? 

1. is there any issue with setting up multiple WHERE parameters in the aspx markup for linqdatasource but then deciding which ones actually get used at runtime by setting the actual WHERE clause at run time? Would the unused parameters simply be ignored and cause no issues?

2. when you need to modify WHERE clause or WHERE parameters at runtime do you need to do so in an event handler? such as linqdatasource.selecting?
I see from the above link it is possible, but is that the standard way to handle controlling filtering in code behind for linqdatasource?

2b. if you use an event such as linqdatasource.selecting to add where parameters and/or modify the where clause in code will that also break the builtin sorting and paging support of the linqdatasource with a gridview? 

HTTP Post and WebService


I am working on a application which will accept the data in the post request. My application also wants to expose a web service and want to call another web service. Considering all these 3 action that I want to do, can I create a single application which will have a web form which will accept the POST request and expose a web service at the same time.

Although it may be possible to achieve this, Is this a correct way of doing it?

server side does not save data when using POST data to another URL using WebRequest


 I am using a IIS 7.5 on Windows 7. I have a simple application that uses System.Net.WebRequest to POST data to another URL (in fact, the server side URL is on my local computer and it is hosted in IIS 7.5).

  1.  The problem is the server does not save data from client although on the client side codes when I debug and I see the OK message return from the code line

   response.StatusDescription; // this has value of "OK"
2. How can I debug the server code side where to receive the request from client side who posts the data ?

The following is the codes for client who posts data using System.Net.WebRequest, and codes for server side who received posted data to save to database.

Client side codes: // also run on my local computer

public string PostIntegrationXml(XmlDocument xmlSubmitDoc)




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