asp.net-mvc-2

Can I create a web service that streams a pdf for download

£可爱£侵袭症+ 提交于 2020-01-02 08:25:29
问题 I don't have much experience with web services, but I think I have a problem for which a web service would work great. My company has just purchased a .net version of Cete Pdf Merger (great product btw). We use both .Net & asp code and will likely use java in the future as well. The scenario is that one technology (asp, java, .net) would have a list of raw data such as an array of field names & values. This data would be posted to the web service that would then open a given pdf, match pdf

ASP.NET Request Validation Exception Even When Validation Is Disabled

不打扰是莪最后的温柔 提交于 2020-01-02 07:54:06
问题 I am using ASP.NET MVC 2, .NET 4.0. I have a controller that disables request validation: [AcceptVerbs("POST")] [ValidateInput(false)] public ActionResult Add(string userId, FormCollection formValues) { //... } and I still get a HttpRequestValidationException when a POST contains HTML: System.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (ThisWeek=""). at System.Web.HttpRequest.ValidateString(String value, String

ASP.NET MVC 2 - Implementing custom Metadata and Validator Providers

好久不见. 提交于 2020-01-02 07:51:11
问题 With the preview 2 release of ASP.NET MVC 2, we now have base classes to implement our own custom providers for metadata and validation. Specifically, with ModelMetadataProvider and ModelValidatorProvider. There isn't a lot of documentation on these yet (just released yesterday as a preview , so I'm neither surprised nor disappointed). Has anyone gotten custom implementations of either of these working? A very simple example (metadata and validator for just "Required") would be great! Perhaps

ASP.NET MVC: Why can't I set ShowForEdit model metadata with an attribute?

被刻印的时光 ゝ 提交于 2020-01-02 06:57:07
问题 Why can't I set ShowForEdit model metadata with an attribute? It seems that the only attribute provided to alter this is [ScaffoldColumn] , which sets both ShowForEdit and ShowForDisplay , which is not what I want to do. I want to be able to annotate the two separately from on my model. 回答1: Because it is not supported out of the box. AFAIK the reason is because the dataannotations attribute that support this functionality are in .net 4.0 and in order to make MVC 3.5 and 4.0 compatible they

Localizing Error Messages In ASP.NET MVC 2 (Default Validation Attributes)

試著忘記壹切 提交于 2020-01-02 05:55:28
问题 i'm working on a multi language website and i want to localize the validation error messages for most of the ValidationAttribute such as [Requried] I know it can be done as Phil Haack have shown in this article. [Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "Required")] but i want to to customize the error message the way i did with my custom Validation Attributes in here : [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =

ASP.NET MVC regex route constraint

核能气质少年 提交于 2020-01-02 02:32:06
问题 I'm having trouble with a specific constraint I'm trying to set up on a route. My URL must look like this one: http://hostname/id-my-title-can-be-that-long where id is composed with digit only and the title is lowercase character with dashes separator. The id and the title are also separated with a dash. For example: http://hostname/123-my-title. Here's my route definition: routes.MapRoute( "Test", "{id}-{title}", new { controller = "Article", action = "Index" }, new { id = @"(\d)+", title =

Convert MVC 2 ASPX into MVC 4 Razor view engine

蹲街弑〆低调 提交于 2020-01-02 02:22:25
问题 I am currently working on MVC 2 with visual studio 2010 and view engine as ASPX kind of project. So I have decided to move with Visual studio 2012 with MVC 4 and view engine as Razor . So could I achieve above task.If so How ? I would like to hear your experience for similar kind of situation. Note : My project is a large one. 回答1: Create a new MVC4 project in Visual Studio 2012 and add source files from your old solution to your new solution one at a time. Moving from MVC3 to MVC4 is easier

Mocking HttpRequest and HttpResponse for MVC Application

社会主义新天地 提交于 2020-01-02 01:05:32
问题 I'm currently writing some unit tests to check the functionality and correct workings of the ASP MVC application that we have written. In this MVC Application, I'm using a special ActionFilterAttribute that allows for authentication when making requests to the MVC Application. The code for this ActionFilterAttribute is this: using System; using System.Security.Authentication; using System.Text; using System.Web.Mvc; using TenForce.Execution.Framework; using TenForce.Execution.Api2

Is this bug ?…got reason behind circular reference … how to solve but?

≡放荡痞女 提交于 2020-01-02 00:20:14
问题 i have asp.net mvc application where my model has a relation like "Question can have multiple answers". So while creating its .dbml file and classes question class would contain the EntitySet right? but each object in the EntitySet (means Answer object) will having the Property as "Question" , so framework automatically creates there circular reference and dependencies. which does comes in focus when we going to serialize the List of Question (List) to generate the json output, for particular

Need a Regex for comma separated number list

╄→гoц情女王★ 提交于 2020-01-01 19:15:43
问题 This should be simple for experienced regex writers, but I don't write them much, so.... I want to do input validation on a text box on a C# MVC form, possibly using javascript or jquery. I want to limit the input to a list of comma-separated integers. The list must start with a number >= 0, followed by a comma and then repeat this pattern. the list may or may not end with a comma: 1,2,444,5, - Pass 1,2,444,5 - Pass ,1,2,444,5, - Fail ,1,2,444,5 - Fail 1,,2,444,5 - Fail 1,,2,444,5,, - Fail I