asp.net-mvc-2

How can I override a .svc file in my routing table?

六眼飞鱼酱① 提交于 2019-11-29 23:44:30
I have this URL that was used from some JSON post back from the main website: http://site/Services/api.svc/UpdateItem We are in the process of updating the web site slowly to ASP.Net MVC 2 and don't want to break any current URL's in the system. (JavaScript refresh issues) I have deleted the /Services/api.svc and have moved the logic for this API call into the following Controller: http://site/LegacyApi/UpdateItem Unfortunately, when adding the route, I can't seem to get it to override the api.svc and keep getting a 404 error. Route: routes.MapRoute( "UpdateItemApi", "Services/api.svc

ASP.Net MVC background threads for email creation and sending

吃可爱长大的小学妹 提交于 2019-11-29 22:41:07
I'm looking at postmarkapp.com to handle the sending of email from my asp.net mvc 2 application using the .net library that they provide: postmark-dotnet library In their documentation they mention that sending emails w/ attachments can take some time and its better to do this in a background job. For my application I could be sending anywhere from 10 to 500 personalized emails some with attachments in a batch to my users. What is the best way to do this background processing in a non blocking way to the admin user that initiated the creation and sending of these emails in ASP.Net MVC? What

Custom Data Annotations ASP.NET MVC C#

旧街凉风 提交于 2019-11-29 22:40:05
I have the follwing question about MVC 2 with C#. Here is my Model: public class Pmjob { [Tooltext="Hier soll der Name eingegeben werden"] [DisplayName("Type")] public int Name { get; set; } } Now I want to reach the Tooltext item in my view, e. g.: @Html.ToolTextFor(Model => Model.Pmjob.Name) or in the BL: if ( Model.Pmjob.Name.Tooltext == "") { } Is this possible? Create an abstract class MetaDataAttribute : public abstract class MetadataAttribute : Attribute { /// <summary> /// Method for processing custom attribute data. /// </summary> /// <param name="modelMetaData">A ModelMetaData

Are multiple asserts bad in a unit test? Even if chaining?

a 夏天 提交于 2019-11-29 22:10:51
Is there anything wrong with checking so many things in this unit test?: ActualModel = ActualResult.AssertViewRendered() // check 1 .ForView("Index") // check 2 .WithViewData<List<Page>>(); // check 3 CollectionAssert.AreEqual(Expected, ActualModel); // check 4 The primary goals of this test are to verify the right view is returned (check 2) and it contains the right data (check 4). Would I gain anything by splitting this into multiple tests? I'm all about doing things right, but I'm not going to split things up if it doesn't have practical value. I'm pretty new to unit testing, so be gentle.

A default document is not configured for the requested URL, and directory browsing is not enabled on the server

主宰稳场 提交于 2019-11-29 21:22:21
I have just deployed my asp.net mvc-2 website to a server (using dotnetpanel). But getting this error A default document is not configured for the requested URL, and directory browsing is not enabled on the server. What settings I needs? Its dotnetpanel based hosting server. Which version of IIS is your host running? One thing to try is to put a dummy default.aspx file in the root folder (this will not be used when MVC is working, but can get rid of this problem). The answer marked will help you eliminate the error but it will not get MVC working. The answer to the problem is to add this line

HandleErrorInfo using MVC2 - Model is null?

…衆ロ難τιáo~ 提交于 2019-11-29 21:16:21
问题 I have an MVC 2 web application, which is nearing release. Until now I have had custom errors turned off but I would like them working when I go production ready. I have set up my web.config with the following: <customErrors mode="On" defaultRedirect="/Error/"> <error statusCode="404" redirect="/Error/NotFound "/> </customErrors> The 404 one works perfectly, and NotFound is an action which maps directly to a View that just shows a pretty standard 404 page using my own Site.Master file. For

How do I use VaryByParam with multiple parameters?

删除回忆录丶 提交于 2019-11-29 21:09:39
In ASP.NET MVC2 I use OutputCache and the VaryByParam attribute. I got it working fine with a single parameter, but what is the correct syntax when I have several parameters on the method? [OutputCache(Duration=30, VaryByParam = "customerId"] public ActionResult Index(int customerId) { //I've got this one under control, since it only has one parameter } [OutputCache(Duration=30, VaryByParam = "customerId"] public ActionResult Index(int customerId, int languageId) { //What is the correct syntax for VaryByParam now that I have a second parameter? } How do I get it to cache the pages using both

What to keep in mind when developing a multi-tenant asp.net MVC application?

北城余情 提交于 2019-11-29 21:08:23
Good afternoon - I have a pretty general question today - I've been tasked with creating a web application to manage some basic information on customers. It's a very simple application, but what I don't know is what to keep in mind to develop the site around supporting multiple users at their own domains or subdomains of our url? How would I restrict users from logging in to each others portion of the app? I've seen mention of database scoping in similar questions on Stack Overflow, could anybody elaborate on best practices for an implementation like this? Are there any new features in MVC3 to

Handling Multiple Roles in MVC - Action-based Accessibility

不羁的心 提交于 2019-11-29 20:31:24
I currently have a project that I seem to have ran into an issue regarding Roles and thought I would get some opinions on how to best handle the problem. The system will require editable, flexible roles that control not only the access of specific areas, but also the use of system functions (Adding Users, Editing Users, Viewing Reports etc.) The system currently allows users to have multiple roles, each of those roles has explicitly defined areas of access/actions, for example: Role A can access areas 1,2,3 and can Add Users. Role B can access areas 1,5,7 and can Modify Users. Role C can

Custom Validation Attribute MVC2

我们两清 提交于 2019-11-29 19:16:56
问题 I have a custom validation attribute which checks to see if two properties have the same values or not (like password and retype password): [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class EqualToPropertyAttribute : ValidationAttribute { public string CompareProperty { get; set; } public EqualToPropertyAttribute(string compareProperty) { CompareProperty = compareProperty; ErrorMessage = string.Format(Messages.EqualToError,