asp.net-mvc-2

The SMTP server requires a secure connection or the client was not authenticated

落爺英雄遲暮 提交于 2019-11-28 08:55:25
I am getting this error The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. e17sm974159fak.34 Web.config <mailSettings> <smtp deliveryMethod="Network" from="emailaccount@gmail.com"> <network defaultCredentials="false" host="smtp.gmail.com" port="587" userName="emailaccount@gmail.com" password="12345678" /> </smtp> </mailSettings> Code file public void Submit() { EnsureCurrentlyValid(); // Send via email var message = new StringBuilder(); message.AppendFormat("Date: {0:yyyy-MM-dd hh:mm}\n",

JSON Date parameter passed to MVC Action is always null

偶尔善良 提交于 2019-11-28 08:54:52
问题 I have a range of parameters that are passed via jQuery Ajax to an MVC JsonResult action. For the most part, these arrive successfully, but there is a Date value that is not arriving at all. What considerations / formats do I need to use - or what approaches do I need to take - in order to get this date to arrive successfully? ...other code ... myStory.Deadline = new Date($('#story-deadline').val()); $.ajax({ url: '/Project/' + action[2] + '/AddStory', data: { Summary: myStory.Summary, Size:

Migrating legacy ASP.NET to MVC 2 (RC): HttpApplication events not firing, User principal is null

岁酱吖の 提交于 2019-11-28 08:47:58
问题 Problem I am trying to take an existing ASP.NET web application and manually migrate it over to use MVC 2 (I am currently running the RC). I followed several steps (I'll list in a moment) and seemed to have it working, but then I noticed I can't set the AuthorizeAttribute because User is null on the controller. Then I noticed that when I navigate to an action, none of the HttpApplication's usual lifecycle events are being raised (such as BeginRequest, etc.). I figure that's probably related

How to stop MVC caching the results of invoking an action method?

♀尐吖头ヾ 提交于 2019-11-28 08:46:22
I am experiencing a problem with IE caching the results of an action method. Other articles I found were related to security and the [Authorize] attribute. This problem has nothing to do with security. This is a very simple "record a vote, grab the average, return the avg and the number of votes" method. The only slightly interesting thing about it is that it is invoked via Ajax and returns a Json object. I believe that it is the Json object that is getting cached. When I run it from FireFox and watch the XHR traffic with Firebug, everything works perfectly. However, under IE 8 the "throbber"

what is the use of RouteValueDictonary routeValues in Html.BeginForm()

断了今生、忘了曾经 提交于 2019-11-28 08:40:07
问题 @{ ViewBag.Title = "About Us"; } @using (Html.BeginForm(new RouteValueDictionary { {"Action","Index"}})) { <input type="submit" value="submit"/> } When I render <form action="/Home/Index" method="post"><input type="submit" value="submit"/> Is this the actual use of RouteValueDictonary. If so I can do this do by HTML.BeginForm("About","Home") Can some one explain the actual use of RouteValueDictonary. Any help will be appreciated. 回答1: This is also useful when implementing the

Binding arrays with missing elements in asp.net mvc

▼魔方 西西 提交于 2019-11-28 08:36:24
I am trying to bind a dynamic array of elements to a view model where there might be missing indexes in the html e.g. with the view model class FooViewModel { public List<BarViewModel> Bars { get; set; } } class BarViewModel { public string Something { get; set; } } and the html <input type="text" name="Bars[1].Something" value="a" /> <input type="text" name="Bars[3].Something" value="b" /> <input type="text" name="Bars[6].Something" value="c" /> at the moment, bars will just be null. how could I get the model binder to ignore any missing elements? i.e. the above would bind to: FooViewModel {

ASP.NET MVC 2 - Binding To Abstract Model

我与影子孤独终老i 提交于 2019-11-28 08:34:10
If i have the following strongly-typed view: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<XXX.DomainModel.Core.Locations.Location>" %> Where Location is an abstract class. And i have the following Controller, which accepts a strongly-typed Model via a POST: [HttpPost] public ActionResult Index(Location model) I get a runtime error stating "Cannot Create Abstract Class Which of course makes sense. However - i'm not sure what the best solution is here. I have many concrete types (around 8), and this is a view where you can only

css3pie in MVC, where to place the pie.htc file?

佐手、 提交于 2019-11-28 08:30:51
I've been trying to use the Css3pie in my MVC project to render rounded corner panel but have no luck so far. I follow the sample with normal html page and it works perfectly but not in my MVC project. I think it is something to do with the path of the 'pie.htc' file that is being confused in MVC I place the 'pie.htc' file in project folder (root) and in my css file, i use: behavior: url(/PIE.htc); I think the MVC router needs to be modified to accept htc file extension? Sorry im new with MVC. Has anyone tried pie.htc and have it working in MVC project, please help? Thanks! As a side note (and

In ASP MVC, how can I return a new view AND a file to the user?

帅比萌擦擦* 提交于 2019-11-28 08:28:29
问题 Thought I would pose this to the StackOverflow crowd since I've run out of ideas. I have a request from users that once a button is clicked, a PDF form is generated which they would like to automatically view, and once they close the PDF the page will already be a "Final page", not the page they clicked the button from. In my pre-final page with the button, the controller calls: return File(finalForm, "application/pdf", Server.HtmlEncode(finalForm)); But this has now passed the control to the

Why Html.Checkbox(“Visible”) returns “true, false” in ASP.NET MVC 2?

烂漫一生 提交于 2019-11-28 08:08:37
I'm using Html.Checkbox("Visible") for displaying a check box to user. In post back, FormCollection["Visible"] value is "true, false". Why? in view: <td> <%: Html.CheckBox("Visible") %> </td> in controller: adslService.Visible = bool.Parse(collection["Visible"]); That's because the CheckBox helper generates an additional hidden field with the same name as the checkbox (you can see it by browsing the generated source code): <input checked="checked" id="Visible" name="Visible" type="checkbox" value="true" /> <input name="Visible" type="hidden" value="false" /> So both values are sent to the