asp.net-mvc-3

Form Cookie Expiring too soon on production server

时间秒杀一切 提交于 2020-01-24 21:06:17
问题 i have following settings in web.config <authentication mode="Forms"> <forms loginUrl="~/Account/login" slidingExpiration="true" timeout="2880" protection="All" /> </authentication> but the cookie expires in less than five minutes of inactivity. Any clue on what is happening? 回答1: I recognize this behavior from a web host where I run one of my sites. It all started when moving to new servers, prepared for dotNET 4. The web.config is completely ignored and, as you mention, five minutes seems

Is there a way to resolve nested interfaces on DTOs in a razor view?

南楼画角 提交于 2020-01-24 20:19:08
问题 We are having an issue with the Razor view engine not resolving nested interfaces. Sample code: public interface IDto { Guid Id {get;set;} } public interface IUserDto: IDto { string Username {get;set;} } //The view @model IUserDto //pukes on this line @Html.DisplayFor(u => u.Id) Should we be using concrete models on our views? Is the Razor view engine not capable of using multiple interfaces per model? 回答1: This was a change in ASP.NET MVC 3 that I already brought to the attention of

ASP.NET MVC @Url.Action includes current route data

江枫思渺然 提交于 2020-01-24 20:16:07
问题 Suppose I: Have a route {controller}/{action}/{id} in my Global.asax file. A Controller Foo and Action Bar(String id) returning a view. A very simple View containing a URL rendered by @Url.Action("bar", "foo") - explicitly NOT specifying an id . If I browse to /foo/bar/test , the view will show the rendered URL as /foo/bar/test . I would have expected that it should be /foo/bar as I didn't specify a value for id . Why would it include the current id even when I didn't specify it, and is there

Hide webgrid column “Edit” link based on condition in MVC3

前提是你 提交于 2020-01-24 19:50:06
问题 I have a webgrid MVC3 contains 4 columns Name, Address, age & Edit. I want to hide Edit link for row if age is greater than 55. Help me to do it. Is there any event like OnItemDataBound event? Thank you 回答1: Is there any event like OnItemDataBound event? No, there is no such concept as events in ASP.NET MVC. You could use a custom format column. Model: public class PersonViewModel { public int Id { get; set; } public string Name { get; set; } public string Address { get; set; } public int Age

SpecFlow + Selenium2 + ASP.NET MVC + TeamCity Not Working

好久不见. 提交于 2020-01-24 15:05:26
问题 I have some SpecFlow features which are using Selenium 2 to automate some UI testing of an ASP.NET MVC 3 application. When I run these locally, it runs fine and the tests pass. Once committing my changes to Git and pushing the commits to our remote repository for our TeamCity instance to pick up, the tests run and take a hell of a lot longer, only to fail with the following. Test(s) failed. OpenQA.Selenium.WebDriverException : No response from server for url http://localhost:7055/hub/session

SpecFlow + Selenium2 + ASP.NET MVC + TeamCity Not Working

被刻印的时光 ゝ 提交于 2020-01-24 15:05:09
问题 I have some SpecFlow features which are using Selenium 2 to automate some UI testing of an ASP.NET MVC 3 application. When I run these locally, it runs fine and the tests pass. Once committing my changes to Git and pushing the commits to our remote repository for our TeamCity instance to pick up, the tests run and take a hell of a lot longer, only to fail with the following. Test(s) failed. OpenQA.Selenium.WebDriverException : No response from server for url http://localhost:7055/hub/session

SpecFlow + Selenium2 + ASP.NET MVC + TeamCity Not Working

只谈情不闲聊 提交于 2020-01-24 15:04:05
问题 I have some SpecFlow features which are using Selenium 2 to automate some UI testing of an ASP.NET MVC 3 application. When I run these locally, it runs fine and the tests pass. Once committing my changes to Git and pushing the commits to our remote repository for our TeamCity instance to pick up, the tests run and take a hell of a lot longer, only to fail with the following. Test(s) failed. OpenQA.Selenium.WebDriverException : No response from server for url http://localhost:7055/hub/session

MVC Url Routing For custom url

萝らか妹 提交于 2020-01-24 12:15:07
问题 I want to pass url link like http://localhost:24873/Jobs/[companyname] or http://localhost:24873/[companyname]/Jobs/ (Preferred) I tried below routing in global aspx file and created controller named Jobs and Index action result with Jobs folder but not working. routes.MapRoute( "JobList", // Route name "Jobs/{companyname}", new { controller = "Jobs", action = "Index", companyname = string.Empty } ); And my controller: public partial class JobsController : Controller { public ActionResult

Ambiguous action method call, for some reason ASP.NET MVC 3

时光总嘲笑我的痴心妄想 提交于 2020-01-24 12:03:33
问题 ers! I'm a bit of a noob with this whole MVC thing, and I have run into a problem that I need some help with. I am currently working on a project for a company that manages foster children, and the main part of this project is an MVC web app for some forms that foster parents must regularly submit to the company. My biggest problem so far has been saving the data that has been entered into the form back to the database. But I recently had a breakthrough when I realized that I could do this:

MVC 3 model foreach filter

不羁岁月 提交于 2020-01-24 10:34:08
问题 I have the following razor syntax @{ foreach (var p in Model) { <b>@p.Age</b> } } I would like to filter the foreach loop to only look at the Model records where p.City = "New York" What would my syntax look like ? I hope that I am explaing this right. Thanks 回答1: @foreach (var p in Model.Where(i => i.City == "New York")) { <b>@p.Age</b> } You might decide to do this filtering in the controller action, depending on whether you need other model records that don't have a city of "New York" in