asp.net-mvc

How to pass a generic object to a Aspx page

I am working on an ASP.Net MVC website and I am stuck on a getting my C# code using generics to play nice with my views. I have a Controller that passes a Model to a View (so far so good). The Model is of type IDescribedEnumerable<T> with some constraints on T, among those is the constraint that T inherits from an interface (IDescribedM...

asp.net MVC routeengine doesn't kick in

Hi, i'm having a bit of a weird problem. I programmed a asp.net mvc app and runned locally at http://localhost:1234/ it works fine. i have a route for /employee and this route kicks in. But when i move it to my webserver at http://myapp.mydomain.nl (it is at a subdomain 'myapp') the /employee route doesn't kick in (i get a 404). i have...

Testing the User.IsInRole in MVC.NET

Dear All, I am trying to test the User.IsInRole("Administrator") in my application, and actually trying to assign the User Role to ("Administrator") so that my test will pass. I am using Scott Hanselman's MvcMockHelpers to do this, and at the moment I have the following test. [Test] public void Create_CanInsertNewArticleView_I...

Unit Testing An Extension Method on HtmlHelper

I have an HTMLHelper extension method that outputs HTML to Response.Write. How best to unit test this? I'm considering mocking the HtmlHelper passed into the method, but am unsure as to how I should verify the HTML sent to Response.Write. Thanks ...

ASPXAUTH cookie is not being saved.

Hi, Im working on a web project in ASP .NET MVC 2. In this project we store some info inside an ecripted cookie (the ASPXAUTH cookie) to avoid the need to query the db for every request. The thing is the code for this part has suddenly stopped working. I reviewed the changes made to the code on the source control server for anything ...

Multiple file upload like orkut style with asp.net mvc..

Hai Guys, Recently i am working with asp.net mvc... Now i want to upload multiple file uploads like orkut style with asp.net mvc ... I dont know how to get started ... ...

asp.net mvc user authentication/permission

i'm new to asp.net mvc and starting the following project. The company wants an intra-net website for various groups of people to upload files to a database, run reports off the it and amend data in several master tables in the database. The company use Active Directory and do not want the users to log in again to use the web site. The w...

How to map EditModel to Command Messages?

Jimmy Bogard at Los Techies says that he maps his EditModel to Command Messages instead of mapping EditModel to DomainModel. Can anyone explain this further? ...

[asp.net mvc] Using a filter to execute a different action?

I want to avoid having lots of if Request.IsAjaxRequest() in my controllers. I was thinking that if I could condense this logic to an ActionFilter it would be easy to adopt a convention in my application to provide a second action for any request that may use Ajax, while providing a fall back if JavaScript is disabled. public ActionRes...

ASP.NET MVC + jqGrid without AJAX

I have an ASP.NET MVC application which is executing a search against a products database. I want to display the results in a jqGrid using the TreeGrid module. I don't really need the grid to be AJAX-y because the data is static and it is small enough that it can all be sent to the client at once. First question: how do I set up jqGri...

How to Create an ASP.NET MVC HTML.DropDownList with Static Items?

I would like to create a DropDownList containing 2 items: Part Name and NSN. This dropdownlist will be used as part of a search box control that will be a partial render as part of my master page. The user will enter their search text and select either Part Name or NSN from the dropdownlist and click submit. The query will return resu...

Radiobuttons to display data in MVC app

I'm looking for a better way to use RadioButtons in a form contained inside an MVC view to display data. One example I'm currently working with is displaying the Role in which a MembershipUser belongs. What I'm doing is setting values on string variables to output in my input tags that will set the RadioButton as checked where necessary...

ASP.NET MVC Unit Testing RedirectResult

Hi, I have a class that inherits from System.Web.Mvc.RedirectResult which overrides ExecuteResult. How do I unit test this? Thanks. ...

How can I create my ASP.NET MVC controller actions so they accept Files?

I've been working all weekend on a Messaging system for my website so users can send and receive messages on my site internally. I have my table schemas worked out, and right now I can send basic messages to different users. Now, I'm working on the attachments portion. How can I create my action methods so that they accept Files? Ide...

ModelState auto adding errors?

Hi folks, I have a controller that should add a person to the db, but in the form I have fields for two kinds of person and only one should be add, then when I post it verifies if it is a pf (type 1) or pj (type 2) person, then I do the validation stuff based in the kind of person it is, that's ok, but even if I don't add any error beca...

Multiattribute custom validtors

I was looking at this article on custom validators in aps.net mvc 2 and I was wondering how I might go about creating a more complex validation which worked on multiple fields at once. Say something like if(fieldA > 7 and fieldB < 15) The attribute method of creating validators doesn't seem like it would work for that. ...

in asp mvc, can I dynamically generate javascript?

On my aspx view, I would like to generate javascript where some parts are generated: before generation: <script type="text/javascript"> var A = 'an id'; var B = "http://www.yahoo.com" + <%= Model.pathname %>; </script> After generation: <script type="text/javascript"> var A = 'an id'; var B = "http://www.yahoo.com/v...

asp.net-mvc and webforms co-existing

I know I've asked this question before, and I know there are plenty of resources out there describing the technique but I cannot for the life of me work it out. I began by creating a simple WebForms application. I then added the Views and Controllers folders. I then added home and shared folders to the views and added an Index.aspx and...

MVC DropDownList option first one updating TryUpdateModel correctly

I have a select list which populates provides an empty value as the first option in the following line. Value = "0" Display = "Select a customer type" <%= Html.DropDownList("Customer.CustomerType", Model.CustomerTypes, "Select a customer type", new { style = "width:200px" })%> The problem is when I pick any option (say 1 or 2 or 3) - ...

Linq to SQL in ASP.Net MVC Runs as Network Service when using Impersonation

I have an ASP.Net MVC controller action that instantiates a DataContext object and I am currently passing the connection string directly into the constructor. I am using Impersonation and I have verified the current user in the controller action is the current Windows Auth. user of the web app, however when running a SQL Trace the query...