MVC ::  post To An action It gets Null Values In Hosted Enviroment?

Jul 12, 2010

I am having a problem where when I form post to an action it gets null values in my hosted enviroment although if I use a model to bind to it works fine. Everything posts and works correctly when I run the project.

So far I have tried to pass the form fields back as parameters on the action and get the value through the context request. Both work fine but as soon as I publish it to the hosted enviroment, it doesn't work. in the view I have:

<%=Html.TextBox("subject") %>

<%=Html.TextBox("comment") %>

for the action Method:

[HttpPost]

[Authorize]

public ActionResult Reply(int? id, string subject, string comment)

{

//Some code...

}

I have verified that it is hitting the action but the subject and comment values are null. I am guessing I am missing something simple, maybe a security setting in the config, that is causing this since I am still fairly new with MVC. I am running VS 2008 with MVC2.

View 4 Replies


Similar Messages:

MVC :: How To Get The IDictionary<Int32, String> Values On The POST Action

Apr 1, 2010

I am working with MVC2 and one of the view model's properties is IDictionary<Int32, String>.

This is not to be changed on the view. But when the form is posted back I would like to still get those values.

Can Html.Hidden store this property values?

How should I do this so the model still gets the IDictionary<Int32, String> values on the POST action?

View 2 Replies

MVC :: Arrays And Post Events / Array Values Dont Become Null?

Feb 17, 2010

What are the issues that needs to be addressed while handling the post event so that array values dont become null ?

View 4 Replies

MVC :: Post Method In MVC - Public ActionResult MyPost Obj.labels Is Null Whereas Name And Description Contains Updated Values

Feb 17, 2010

I am using ASP.net MVC for the developement. My Model class looks like

class MyModel
{
string name;
string desc;
string[] labels;
}

When I bind this model to the view, all the values are displayed on the view successfully. But on Postback method public ActionResult MyPost(MyModel obj) obj.labels is null whereas name and desc contains updated values. why is it so?

View 6 Replies

MVC :: Controller Invokes GET Action Instead Of POST Action

May 20, 2010

I'm trying to add file upload functionality to a page. I've got a form that posts the selected file to a controller with a 'savefile' method. But if I don't add a get version of 'savefile' I'll get a 404 error. Here is the form code which is presented on the Index page:

[Code]....

And here is the controller code:

[Code]....

Intuitively I don't think I should need a GET version of SaveFile but if omit it I get a 404 error when the form posts. Why should I need a GET version of SaveFile when all I want is to post a form and save the file?

View 4 Replies

IIS Configuration :: JScript Serialize Returns Null When Website Hosted On Server?

Feb 25, 2016

when application runs on local machine, it returns data correct, but when website hosted on server then it cannot retunrs data in jscript serialize

C#
JavaScriptSerializer jscript = new JavaScriptSerializer();
List<ListItem> items= new List<ListItem>();
return jscript.Serialize(items);
Javascript
var jsdata = JSON.parse(items);

View 1 Replies

MVC: Post Dropdown Box Value To Action?

Jan 23, 2011

@using (Html.BeginForm("Index", "Bill"))
{
@Html.Label("FromDate")
@Html.DropDownList("FromDate",Model.DateList)
@Html.Label("ToDate")
@Html.DropDownList("ToDate", Model.DateList)
@Html.ActionLink("Filter", "Index", "Bill") // I want to post to Index
}
[HttpPost]
public ActionResult Index(string fromDate, string toDate)
{
//Process
}

What is the correct way to post the date range to Index action?

What kind of URL do I need to specify?

View 1 Replies

MVC :: Post Action Model Parameter

Jan 26, 2011

i wonder something about mvc post method. for example I created a view "strongly typed" from a model (MyModel).

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Demo1.Models.MyModel>" %>
for Create actionsthere is two way.
first one takes MyModel as parameter
[HttpPost]
public ActionResult cart(MyModel md, int someID)
{
//some code
//.....
return View(MyModel);
}
second one does not take parameter as model.
[HttpPost]
public ActionResult cart(int someID)
{
//some code
//.....
return View(Mymodel);
}

for first one way, after form post the form values does not delete, I mean form does not cleared,after second one form is be cleared. why this diffirence?

View 5 Replies

MVC :: JQuery Post To An Action Method?

Oct 19, 2010

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:

[Code]....

And my action method:

[Code]....

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

View 1 Replies

MVC :: Htmlbeginform (post) Does Not Fire Action?

Mar 2, 2010

I must miss something obvious here when using htmlbegin form. I noticed that it takes (or tries to take me) right to the view rather than the an action. If I replace SearchAction with SearchResult is goes nicely to the view, not considering the action.

Using SeachAction leads to the error that it cant find the view.

View 12 Replies

MVC :: Redirect To Post Method/Action?

Mar 28, 2011

I have an ActionResult that accepts POST, however is there a work around for me to redirect from a controller to another controller containing this POST method/action?

View 3 Replies

C# - Change Action Of Checkbox To Get Instead Of Post?

Mar 26, 2010

We have an ASP.Net page that uses a checkbox to toggle between a list view and a tree view. The problem is that this triggers a post. When we then click on one of the documents in the list, then press back in the browser, we get a page expired error. Is it possible to change the action of the check box to trigger a get with a parameter?

View 1 Replies

C# - MVC - Using Model Property As Form - Post To Action?

Jan 12, 2011

public class BandProfileModel
{
public BandModel Band { get; set; }
public IEnumerable<Relationship> Requests { get; set; }
}
and the following form:
<% using (Html.BeginForm()) { %>
<%: Html.EditorFor(m => m.Band) %>
<input type="submit" value="Save Band" />
<% } %>
which posts to the following action:
public ActionResult EditPost(BandProfileModel m, string band)
{
// stuff is done here, but m is null?
return View(m);
}

Basically, I only have one property on my model that is used in the form. The other property in BandProfleModel is just used in the UI for other data. I'm trying to update just the Band property, but for each post, the argument "m" is always null (specifically, the .Band property is null). It's posting just fine to the action, so it isn't a problem with my route. Just the data is null.

The ID and name attributes of the fields are BAND_whatever and Band.whatever (whatever being a property of Band), so it seems like it would work. What am I doing wrong? How can I use just one property as part of a form, post back, and have values populated via the model binder for my BandProfileModel property in the action?

View 2 Replies

Web Forms :: Capture Which Action Cause An Post Back?

May 13, 2010

i am thinking to capture which button has caused a postback in the web pages.

Is it possible to do so?

View 2 Replies

MVC :: Catch Forunentry Type Into Create Post Action

Jul 4, 2010

i am making a forum application using MVC 2. I have a ForumController which has Index and Create Actions. The Get Create Action returns View and the Post Create Action takes an argument of type "ForumEntry". When i generate create view i make sure that i check "create strongly typed view" and i select models.ForumEntry Model and NOT the models.Forum Model. The Forum model is ADO.NET enitity model that maps to Forum Table. I want to catch ForumEntry type into my Create Post action but mysteriously i get a Forum Object. I have verified this by returning Content When :

[HttpPost]
Public ActionResult Create(ForumEntry entryToCreate)
{
return Content (entryToCreate.Title); // No Output
}

When

[HttpPost]
Public ActionResult Create(Forum entryToCreate)
{
return Content (entryToCreate.Title); // output == new entry that i typed in the create form
}

I am baffled as the create Form is of type FormEntry. Here is the code for create View

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Aspforum.Models.ForumEntry>" %>

View 5 Replies

MVC :: How To Call Post Action Controller From View Using Jquery

May 12, 2010

ia ma working on an asp.net mvc 2 app and i have a Users view, displaying all the users of the database. Then, i would like to add the ablility to display "users starting with fisrt name" capabaility on the same view. For this i created a list of all english leters that actually are links (<a href="#">A</a>, etc...)

I managed to handle the click event of each one of the letters and get the corresponding letter via jquery, but i don't know how to call theHttp.Post Users/FindUserByFirstLetterName(string letter) on the click event.

I cannot use the Html.ActionLink<> helper, since it redirects me to the HttpGet controller action.

I also tried using using jqery.Post but i also couldn't manage to call the action.

View 7 Replies

Web Forms :: Post Message Stating That An Action As Taken Place?

Nov 23, 2010

display a simple modal message stating that an action as taken place?For instance, I have a button on my screen that sends an email. After completing the task I enable a label (visible=true) that states 'Email Sent'.I would rather have something pop up after clicking send mail, stating the email was sent.Do I need to use an AJAX control (popup extender), or is there a simple method of doing this?

View 5 Replies

JQuery Ajax With MVC Action - Passing Arguments From JavaScript In POST

Mar 4, 2011

I have an ASP.NET MVC controller action with the following VB.NET signature:

<HttpPost()>
Public Function ClosestCities
(ByVal position As MapCoordinate, ByVal citiesCount As UInteger) As JsonResult

The MapCordinate class is:

Public Class MapCoordinate
Public Latitude As Double
Public Longitude As Double
End Class

If I'm trying to send an Ajax POST in jQuery to the ClosestCities action, what should my request look like?

When I use the following code to POST to this action, in the debugger window of VS, position.longitiude and position.latitude are equal to 0.0 (0D):

[code]....

View 2 Replies

C# - Test A MVC2 Post Action With Validation When Using MvcContrib TestHelper?

Oct 12, 2010

I'm attempting to write a unit tests for an ASP.NET MVC 2 post action that takes a view model as its sole parameter. The view model is decorated with validation attributes such as [Required]. I'd like to test two scenarios. The first scenario is when a valid set of data is passed in (ie, all required properties have values) and a redirect to the list page is returned. The second scenario involves passing in invalid data (eg, when one or more of the Required properties are not set). In this case the same view is returned with error messages.The action signature is as follows:

[HttpPost]
public virtual ActionResult Create(NewsViewModel model)

The NewsViewModel class is as follows:

public class NewsViewModel
{
public Guid Id { get; set; }

[code]...

View 1 Replies

MVC Null Model Passed To Controller Action?

Mar 31, 2011

Why is a null parameter being passed to the following controller action?

public FileContentResult GetImageForArticle(ArticleSummary article)
{
if (article == null || !article.ContainsValidThumbNail()) return null;
return File(article.ThumbNail, article.ThumbNaiType);
}

from the following partial view:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<AkwiMemorial.Models.ArticleSummary>>" %>
<%if (Model.Count() > 0) [code]...

View 1 Replies

MVC :: Null Action Id Returns System.NullReferenceException?

Oct 26, 2010

This is what I'm trying to run:

[Code]....

When I browse to www.mysite.com/mycontroller/myaction/myid, everything works ok. But visiting www.mysite.com/mycontroller/myaction produces:Server Error in '/' Application.Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

View 3 Replies

C# - Create A Tar.gz Using .net Enviroment ?

Jul 9, 2010

I am a fresher to .net. is that possible to create a tar.gz using .net enviroment ? if yes how ?

View 2 Replies

MVC :: Posting List Of Checked Items To Controller Action Using JQuery Post?

Feb 16, 2011

I got a list of checkboxes on my form, and a jquery script that catch a button click to get all the selected items (in an array) and post to a controller action.

This is my script: (yes A, looked at your sample but cannot get this to work)

[Code]....

That alert will print out correctly (like 1,3,5).

However when the above post hit my controller action, "selectedInvestments" are null, which I can't figure out why (back to my tekpub jquery videos, can't go on like this)

[Code]....

View 3 Replies

MVC :: Calling Controller Action Using Jquery Post Ajax Call Abondons Session?

Apr 9, 2010

i have a website where i provicde a link. On clicking the link a controller action method is called to generate a zip file after creation of zip file is done, i show the link to download the zip file by replacing the link to create a zip with the link to download the zip.

the problem is that after zip file creation is over and link is shown, when user clicks on the link to download the zip file, they are sent to login. After providing correct credentials in the login page they are prompted to download the zip file. they sould not be sent to the login page. In the action to generate zip file i haven't abondoned the session or haven't not done anything that abondons the session.

the user should not be sen't to login page after successful creation of zip file user should be able to download the file without login. i search internet on this problem, but i did not find any solution. In one of the blog written by hanselman i found this statement that creates the problem with the session: Is some other thing like an Ajax call or IE's Content Advisor simultaneously hitting the default page or login page and causing a race condition that calls Session.Abandon? (It's happened before!)

so i thought there might be some problem with ajax call that causes the session to expire, but i don't know what is happening? it's like this after users click on the link to create zip file the zip file is created successfully but the session gets expired. this is not what i want. Why does the session has to get expired after making a jquery post call to controller action to create a zip file? i hope u understand the problem.

View 5 Replies

Handle Multiple Forms Post Action Under A Parent Form For Same Aspx Page?

Jul 27, 2010

I have an asp.net application in which I have a parent form and in that on load I am adding sub forms dynamically having a submit image button..

When I am clicking the button of one form then I am able to read the hidden variables using request under parent form .But on clicking the second button the hidden variables of parent form are having null value although i have assign the value to them using context variables.

how can i handle mulitple form action for same page

View 2 Replies







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