asp.net-mvc-2

Configuring ASP.NET MVC app's IIS 7.5 Application Pool identity as login on SQL Server 2008 R2

限于喜欢 提交于 2019-12-22 08:28:28
问题 I am trying to use IIS 7.5 Application Pool identity as login on SQL Server 2008 R2 so that my ASP.NET web app can connect to the database... Using this approach worked fine on my local dev machine (IIS 7.5 and SQL Server 2008 R2 on same machine). However, when I try to set up the same on production (IIS and SQL servers are separate) I am unable to add "IIS APPPOOL\MyAppAppPool" login to SQL Server 2008 R2. Notice that in either case you cannot use "Browse..." when creating a login in SQL

What are the key concepts to know when migrating my mindset from ASP.NET to ASP.NET MVC (2)?

坚强是说给别人听的谎言 提交于 2019-12-22 08:26:52
问题 I'm currently working with ASP.NET and about to start learning ASP.NET MVC (2). So before I open the first thick book and go through the first lengthy tutorial, what are the most important (new) concepts to keep in mind? What are the main new features I should be aware of? Thanks a lot. 回答1: No viewstate. No server-side controls. Think RESTful/stateless; it's a request/response cycle, not an event being handled. It's worth consideration to take a side trip into Ruby/Rails to learn the

JavaScript Error: conditional compilation is turned off in MVC2 View

不羁岁月 提交于 2019-12-22 08:23:56
问题 I am trying to call a JavaScript function on click in a MVC2 View Page. <a onclick=" SelectBenefit(<%=o.ba_Object_id %>,<%=o.ba_Object_Code %>)" href="#">Select</a> JavaScript function function SelectBenefit(id,code) { alert(id); alert(code); } Here ba_Object_Id and Code are the values from the ViewModel. If I use SelectBenefit(<%=o.ba_Object_id %>) in this way, its working fine. But when I have two paramaters its not.I am getting this error: conditional compilation is turned off. 回答1: I

ASP.NET MVC 2 RC 2 returns Area-specific controller when no area specified

家住魔仙堡 提交于 2019-12-22 07:37:06
问题 I have a basic MVC 2 (RC2) site with one base-level controller ("Home"), and one area ("Admin") with one controller ("Abstract"). When i call http://website/Abstract - the Abstract controller in the Admin area gets called even though i haven't specified the Area in the URL. To make matters worse - it doesn't seem to know it's under Admin because it can't find the associated view and just returns: The view 'Index' or its master was not found. The following locations were searched: ~/Views

ASP.NET MVC 2 RC 2 returns Area-specific controller when no area specified

两盒软妹~` 提交于 2019-12-22 07:36:07
问题 I have a basic MVC 2 (RC2) site with one base-level controller ("Home"), and one area ("Admin") with one controller ("Abstract"). When i call http://website/Abstract - the Abstract controller in the Admin area gets called even though i haven't specified the Area in the URL. To make matters worse - it doesn't seem to know it's under Admin because it can't find the associated view and just returns: The view 'Index' or its master was not found. The following locations were searched: ~/Views

Enabling html PUT method on IIS 7.5

帅比萌擦擦* 提交于 2019-12-22 07:00:06
问题 I'm doing a iCal Service to allow sync between Calendar instances and runs fantastic on localhost (under VS2010 Web Server) But now That I hosted on a Windows 2008 R2 (IIS 7.5.7600) I couldn't create not even update an event :-o Thunderbird always said So I rush into Fiddler and found out the problem a 405 error That says PUT is not allowed :( How can I enabled this method? Application Pool? WebSite definition? IIS Settings? 回答1: We just need to remove the WebDav Service Control Panel >

Read DataAnnotations from a collection of models in an MCV2 view

纵饮孤独 提交于 2019-12-22 06:56:57
问题 In my MVC2 AdminArea I'd like to create an overview table for each of my domain models. I am using DataAnnotations like the following for the properties of those domain model objects: [DisplayName("MyPropertyName")] public string Name { get; set; } Now my question is: How can I access the DisplayName Attribute if my view receives a collection of my domain models? I need this to build the table headers which are defined outside of the usual <% foreach (var item in Model) { %> loop. Inside this

How should I return an Image from a controller action c# asp.net-mvc-2?

杀马特。学长 韩版系。学妹 提交于 2019-12-22 06:48:12
问题 I am building images from a byte[] like below. public FileContentResult GetEmployeeImage(int empId) { MemoryStream ms = new MemoryStream(byteArray); Image returnImage = Image.FromStream(ms); return returnImage;//How should i return this image to be consumed by javascript. } I want to return this image to the browser via a controller action method, so as it can be consumed by my javascript code and displayed in the browser. How should I do this? 回答1: You don't need to create an image object;

Property Injection into an Action Filter

﹥>﹥吖頭↗ 提交于 2019-12-22 06:27:34
问题 I'm trying to get Property Injection working on a Custom Action Filter Attribute. It is working as it is supposed to, however, I'd like to use DI on the Property itself. My filter looks like this [AttributeUsage(AttributeTargets.Class)] public sealed class HeaderFilterAttribute : ActionFilterAttribute { public IMarketService MarketService { get; set; } public override void OnActionExecuted(ActionExecutedContext filterContext) { var view = (ViewResultBase)filterContext.Result; if (view != null

Asp.net Mvc 2 DisplayFor Performance Issue?

故事扮演 提交于 2019-12-22 05:54:50
问题 In my recent project which is using Asp.net Mvc 2, we found that the DisplayFor has performance issue. I'm not so sure whether it is the real issue or did I miss something? I hope some Asp.net Mvc Guru can explain it to me. :) Model. public class Customer { public int CustomerId { get; set; } public string Name { get; set; } public string Address { get; set; } public string EmailAddress { get; set; } public static IEnumerable<Customer> GetCustomers() { for (int i = 0; i < 1000; i++) { var