Click here to Skip to main content
15,888,401 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: how to add difftent item to a dropdown in each row of grid view Pin
Bikash Prakash Dash13-May-13 3:43
Bikash Prakash Dash13-May-13 3:43 
GeneralRe: how to add difftent item to a dropdown in each row of grid view Pin
mhd.sbt13-May-13 3:45
mhd.sbt13-May-13 3:45 
SuggestionRe: how to add difftent item to a dropdown in each row of grid view Pin
Bikash Prakash Dash13-May-13 3:51
Bikash Prakash Dash13-May-13 3:51 
GeneralRe: how to add difftent item to a dropdown in each row of grid view Pin
mhd.sbt13-May-13 3:53
mhd.sbt13-May-13 3:53 
GeneralRe: how to add difftent item to a dropdown in each row of grid view Pin
dusty_dex13-May-13 5:14
dusty_dex13-May-13 5:14 
AnswerRe: how to add difftent item to a dropdown in each row of grid view Pin
dusty_dex13-May-13 3:48
dusty_dex13-May-13 3:48 
QuestionDisplaying Data Pin
nagesh2113-May-13 0:37
nagesh2113-May-13 0:37 
QuestionMVC - request denied where the query string is too long - RESOLVED Pin
Andy_L_J11-May-13 15:21
Andy_L_J11-May-13 15:21 
Apologies in advance for the long post. I am getting the following error in my MVC app:


HTTP Error 404.15 - Not Found

The request filtering module is configured to deny a request where the query string is too long.


Here is my code:

C#
  public class MailHelper
  {
    public string To { get; set; }
    public string From { get; set; }
    public string Subject { get; set; }
    public string Message { get; set; }
    public string ImageUrl { get; set; }
   
    public MaiHelper() {}

    public bool IsValid()
    {
      return !(EmailDate == null) && !(string.IsNullOrEmpty(To)) &&
		!(string.IsNullOrEmpty(From)) && !(string.IsNullOrEmpty(Subject)) &&
		!(string.IsNullOrEmpty(Message)) && !(string.IsNullOrEmpty(BannerUrl));
    }

  }

// Mail Controller...
  public ActionResult Index()
  {
    MailHelper mH = New MailHelper();
    mH.EmailDate = DateTime.UtcNow;
    mh.From = "some@adress.com";
    
    return View(mH);
  }


I am using an external jQuery library ckeditor to get RTB functionality in my Razor page:.

HTML
  /*Index.cshtml*/
  @Model Controllers.MailHelper
  @{
    Layout = null;
  }
  ...

  @using (Html.BeginForm("Send", "Mail", FormMethod.Get))
  {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    
    <fieldset>
    <legend>MailHelper</legend>

    <table style="width: 700px;">
    <tr>
    <th>Date</th>
    <td>@Html.EditorFor(model => model.EmailDate)
						@Html.ValidationMessageFor(model => model.EmailDate)</td>
				</tr>
				<tr>
					<th>To</th>
					<td>@Html.EditorFor(model => model.To)
						@Html.ValidationMessageFor(model => model.To)</td>
				</tr>
				<tr>
					<th>From</th>
					<td>@Html.EditorFor(model => model.From)
						@Html.ValidationMessageFor(model => model.From)</td>
				</tr>
				<tr>
					<th>Subject</th>
					<td>@Html.EditorFor(model => model.Subject)
						@Html.ValidationMessageFor(model => model.Subject)</td>
				</tr>
				<tr>
					<th>To</th>
					<td>@Html.TextAreaFor(model => model.Message, new { @class = "ckeditor", @id = "text-details" })
						@Html.ValidationMessageFor(model => model.Message)</td>
				</tr>
				<tr>
					<th>Banner Url</th>
					<td>@Html.EditorFor(model => model.BannerUrl)
						@Html.ValidationMessageFor(model => model.BannerUrl)</td>
				</tr>
			</table>

			<p>
				<input type="submit" value="Create" />
			</p>
		</fieldset>
  }
...


It seem that if the Message is too long in the MailHelper.Message field, an error is thrown from my Send method:
C#
[ValidateInput(false)]
				public ActionResult Send(MailHelper mailHelper)
				{
					if (!mailHelper.IsValid())
					{
						return RedirectToAction("Index", "Mail", new { mH = mailHelper });
					}
					dynamic email = new Email("Example");  */Example.cshtml*/
					email.To = "johnstonandy@rocketmail.com";
					email.From = mailHelper.From;
					email.Subject = mailHelper.Subject;
					email.Message = mailHelper.Message;
					email.Banner = mailHelper.BannerUrl;
					email.Send();

					return RedirectToAction("Sent");

				}



I assume the error is caused because I am using the FormMethod.Get parameter. Can someone point this novice in the right direction?

I have looked at changing the requestFiltering/requestLimits in the config but to no avail.

Cheers

-- RESOLVED --

As I should have guessed (found out through more research), the solution was rather trivial:

0) Add HttpPost attribute to Send method.
1) Change formMethod to formMethod.Post in Index.cshtml.
I don't speak Idiot - please talk slowly and clearly

"I have sexdaily. I mean dyslexia. Fcuk!"

Driven to the arms of Heineken by the wife


modified 11-May-13 22:13pm.

Questionwhich IDE software is suitable for ASP.NET? Pin
ramasubbu ram10-May-13 23:35
ramasubbu ram10-May-13 23:35 
AnswerRe: which IDE software is suitable for ASP.NET? Pin
Richard MacCutchan11-May-13 0:03
mveRichard MacCutchan11-May-13 0:03 
SuggestionRe: which IDE software is suitable for ASP.NET? Pin
Bikash Prakash Dash11-May-13 4:29
Bikash Prakash Dash11-May-13 4:29 
QuestionHELP! Multiple apps on same website Pin
ianoseb10-May-13 6:19
ianoseb10-May-13 6:19 
QuestionRe: HELP! Multiple apps on same website Pin
ZurdoDev10-May-13 7:11
professionalZurdoDev10-May-13 7:11 
AnswerRe: HELP! Multiple apps on same website Pin
ianoseb10-May-13 7:27
ianoseb10-May-13 7:27 
AnswerRe: HELP! Multiple apps on same website Pin
ZurdoDev10-May-13 7:28
professionalZurdoDev10-May-13 7:28 
QuestionCreating Blogs Using Asp.net C# Pin
rajugourishetty9-May-13 22:48
rajugourishetty9-May-13 22:48 
AnswerRe: Creating Blogs Using Asp.net C# Pin
Richard MacCutchan10-May-13 0:04
mveRichard MacCutchan10-May-13 0:04 
AnswerRe: Creating Blogs Using Asp.net C# Pin
ZurdoDev10-May-13 7:13
professionalZurdoDev10-May-13 7:13 
GeneralRe: Creating Blogs Using Asp.net C# Pin
rajugourishetty12-May-13 20:41
rajugourishetty12-May-13 20:41 
SuggestionRe: Creating Blogs Using Asp.net C# Pin
ZurdoDev13-May-13 1:05
professionalZurdoDev13-May-13 1:05 
QuestionIncorrect Oracle.DataAccess.ddl reference in web site project Pin
vanikanc9-May-13 3:29
vanikanc9-May-13 3:29 
AnswerRe: Incorrect Oracle.DataAccess.ddl reference in web site project Pin
R. Giskard Reventlov9-May-13 6:59
R. Giskard Reventlov9-May-13 6:59 
GeneralRe: Incorrect Oracle.DataAccess.ddl reference in web site project Pin
vanikanc10-May-13 2:28
vanikanc10-May-13 2:28 
GeneralRe: Incorrect Oracle.DataAccess.ddl reference in web site project Pin
R. Giskard Reventlov10-May-13 4:52
R. Giskard Reventlov10-May-13 4:52 
AnswerRe: Incorrect Oracle.DataAccess.ddl reference in web site project Pin
ZurdoDev10-May-13 7:15
professionalZurdoDev10-May-13 7:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.