asp.net-mvc-2

How does the session state work in MVC 2.0?

家住魔仙堡 提交于 2019-12-10 23:47:54
问题 I have a controller that stores various info (Ie. FormID, QuestionAnswerList, etc). Currently I am storing them in the Controller.Session and it works fine. I wanted to break out some logic into a separate class (Ie. RulesController), where I could perform certain checks, etc, but when I try and reference the Session there, it is null. It's clear that the Session remains valid only within the context of the specific controller, but what is everyone doing regarding this? I would imagine this

Reload MVC2 user control with jQuery

≡放荡痞女 提交于 2019-12-10 23:44:50
问题 I know I've had a ton of questions today, but still trying to get everything under control learning MVC 2 tie right way. Before I get into the question I already tried the solution offered here but I get an 500 internal server error. So here's what I'm trying to do, I give the user the ability to select from a list of skills (loaded in a ListView user control) or add a new one to the list and select that. The adding new one is completed (using a WCF service & jQuery) but now I'm trying to

ASP.NET MVC SiteMap and/or Security Trimming

我怕爱的太早我们不能终老 提交于 2019-12-10 22:08:09
问题 Is there an equivalent in ASP.NET MVC to the SiteMap and Security Trimming Features found in Web Forms? I am just beginning to learn MVC and was looking for a solution to this to prevent going down the wrong path while learning. 回答1: Check ASP.NET MVC SiteMapProvider 来源: https://stackoverflow.com/questions/4647135/asp-net-mvc-sitemap-and-or-security-trimming

WIF cross-domain on one IIS site, dynamically setting of realm

北城余情 提交于 2019-12-10 22:05:21
问题 We have a lot of domains running on one IIS WebSite/AppPool. Right now we are in the process of implementing SSO with Windows Identity Foundation. in web.config the realm has to be set with <wsFederation passiveRedirectEnabled="true" issuer="http://issuer.com" realm="http://realm.com" requireHttps="false" /> My problem is that the realm is dependent on which domain the user accessed the website on so what I did is that I set it in an global action filter like this var module = context

The property 'Id' is part of the object's key information and cannot be modified

早过忘川 提交于 2019-12-10 21:50:09
问题 I have a sample web app that I am writing and im confused why i'm getting this The property 'Id' is part of the object's key information and cannot be modified. when i'm not updating the 'Id'? Ok, so this is what I am trying to do. I have 2 tables Topics and Posts and -- User creates a new topic it should add a topic record on the database Get the topic Id and set that Id to the Post's TopicId Get that post's Id and set it as Topic's LastPostId I'm re updating the post so whenever I need to

Struggling with SelectList in ASP.NET MVC 2

混江龙づ霸主 提交于 2019-12-10 21:43:41
问题 I have a model that looks something like this: public class SampleModel { public static SampleModel Create() { return new SampleModel { Boolean = true, // set several more properties... Colors = new SelectList(new[] { "Red", "Green", "Blue" }, "Green") }; } public bool Boolean { get; set; } // define several more properties... public SelectList Colors { get; set; } } I'm letting ASP.NET MVC automatically scaffold the properties using Html.DisplayForModel() for my Details view and Html

Div as Ajax.ActionLink

前提是你 提交于 2019-12-10 21:11:35
问题 Is it possible to create Ajax.ActionLink which has instead of text, the whole DIV? I'd like to map div on Ajax.ActionLink 回答1: I don't think that this will work using the standard MVC Ajax scripts. I believe that the MVC javascript is created to use an <a> element by default. On a different note, embedding a div tag within an <a> is not valid XHTML. What are you trying to achieve? Using Jquery is probably the easiet way you want to go. As an example: <div onclick="SomeAjaxFunction()">some div

VB.Net Late binding operations cannot be converted to an expression tree

被刻印的时光 ゝ 提交于 2019-12-10 21:09:32
问题 I'm getting some VB.Net Late binding operations and getting this error: Late binding operations cannot be converted to an expression tree. I've searched here and can only find solutions to the SQL get data code, not to my problem. At all my x.NAME lines !? Im new to this so can anyone say me why i get this error.. <div>Navn: <%: Html.EditorFor(Function(x) x.Name)%></div> <h3>Adresse</h3> <div>Linje 1: <%: Html.EditorFor(Function(x) x.Line1)%></div> <div>Linje 2: <%: Html.EditorFor(Function(x)

ASP.NET MVC JsonResult and AuthorizeAttribute

心已入冬 提交于 2019-12-10 20:57:03
问题 What is the most straight forward way to use AuthorizeAttribute and JsonResult together so that when the user is not authorized the application returns a Json error rather than a log in page? The two things I am currently considering are extending AuthorizeAttribute or just making a new attribute that implements IAuthorizationFilter . 回答1: Remove the AuthorizeAttribute from your Action. Then in the first lines of your action, insert this: if (!User.Identity.IsAuthenticated) return Json("Need

How do I access other attribute values from inside a custom ValidationAttribute in an asp.net mvc 2 application?

半城伤御伤魂 提交于 2019-12-10 20:55:58
问题 I'm using asp.net mvc 2 with C# and DataAnnotations. The situation is this: I have a custom control that is strongly typed against a model class. This control is displayed on the view several times but with differing property values, such as headings (Ex: Question 1, Question 2, Question 3, etc.. are all headings). I can write a custom validation class that validates this object as a whole, but the problem is, I can't get specific Html.ValidationMessage(...) tags to display. The validation