asp.net-mvc

Do you know some tools can help to create fake data which was used in unit test of asp.net mvc project

I was using aps.net mvc unit test, and want to create fake data instead of using real database connection, but the Linq query code and real database was huge and complicated, create fake data in unit test which can mimic real database was a huge job! Who knows some tools can help me to create fake data and mimic real database? Thanks! ...

Hide column in telerik Grid but need to get it

let's say i have an order and order details. the view will contains the order fields, and a Telerik Grid for the details i always maintain a reference of the Order in the session. Session["Order"] = order; and when the user add an order detail to the grid, I'm saving it in the Order reference. public ActionResult Grid_AddDetail(Ord...

Data Annotations for a subset of properties

I've been reading up on Data Annotations (i.e. Scott Guthrie's blog post) and I am thrilled about the concept of having validation logic in one place. Has anyone been able to use this technique successfully when prompting the user to enter a subset of the properties associated with a given class? For example (pseudocode)... public c...

How to execute code as a part of the LINQ query

I have a query that looks like this: var results = from person where <here I need to do something like if person is of type Employee, call person.GetSalary() > 100000 but if the person is of type Contractor, I need to execute several lines of code before doing a person.GetSalary() > 100000 sele...

Best way of handle checkboxes in MVC

Hi all, I'm trying to keep the values of checkboxes in a form with the same name (level and coursetype) in the querystring so I can check which ones were selected. In the first submit, I get: Search?coursetype=1416&coursetype=post16&level=3&level=6&level=1 which is fine so I can check the values back into the view and tick the ones pr...

ASP.NET MVC Windows Authentication 403 Forbidden: Access is denied

Hello all, I'm developing an ASP.NET MVC 2 app using Windows Authentication. When I run it within Visual Studio (using the built-in IIS), under the same domain, I was able to login using my credential. But when I deployed it to the server, which is also on the same domain, in-house, I got the "403 - Forbidden: Access is denied." error. ...

what is the main feature of asp.net mvc 3

are anyone tell me the feature of asp.net mvc 3 ...

Full Data output with Jquery filter samples

So, I'm using MVC.net to basically to query data by date range (from - to date) where I have some additional filters I'd like to apply once the data is rendered to my page. I've looked at "FlexiGrid" as a viable option, however I'm having issues with loading my existing JSON data onto it, seeing as the request method requires you to pas...

ASP.NET MVC Routing / SEO Friendly URL

I'm trying to do something like stackoverflow Take a link from stackoverflow for example: http://stackoverflow.com/questions/9033/hidden-features-of-c if you remove the last part (http://stackoverflow.com/questions/9033) it still returns the same result. For my routing in Global.asax I tried doing something like "{action}/{id}/{titl...

Is a redirect less efficient than returning other types of result?

Is a redirect less efficient than returning other types of result? I ask because if my current request is asynchronous I want to return a partial with only relevant data. Otherwise I need to render the entire page. So I'm thinking of returning a redirect to an action method which will return a View. My understanding is that a redirect wi...

ASP.NET MVC 2 validation for variable length or dynamic data views, and view models

OK, so maybe I am really missing something here, but how is it so difficult to do effective server & client side validation in MVC (2)? Here are a few examples: I want to use a variable length list. I follow a great tutorial like Steve Sanderson's variable length list overview. I want to create a custom validator like "RequiredIf". My ...

Role based authentication feed back to user in ASP.NET MVC

Hello, I am using role based Authentication for some of the features in my ASP.NET MVC application by implementing <Authorize(Roles:="Administrator")> _ Function AdminPage() As ActionResult Return View() End Function If the user is not logged in as Administrator this will redirect the user to login page but there is no feed ba...

Allow user to input HTML in asp.net MVC

How can I allow a user to input HTML into a particular field using ASP.net MVC. I have a long form with many fields that get mapped to this complex object in the controller. I would like to make one field (the description) allow HTML which I will preform my own sanitation on at a later point. ...

How to Bind Exclude more than one property from a model with linq to sql asp.net mvc

I have a form with a select box on it. The linq entity has a selectList as a public property on it. I'm currently excluding it from the entity like this [Bind(Exclude = "taskDeadlineTime")] I now want to add a second drop down, and I'm getting this error when I try to UpdateModel() No parameterless constructor defined for this obje...

How to use ASP.Net MVC View inside WebForms .aspx page?

I have a large web application that I have set up as both ASP.Net Web Forms and MVC. Some of the newer pages are MVC (.mvc) and some are Web Forms (.aspx). Since this is a business app and functions are being constantly added, it's hard for me to have the time to stop and replace existing functionality to convert it over. So I would like...

ASP.NET MVC - Unit testing RenderPartialViewToString() with Moq framework?

I'm using this helper method to turn my PartialViewResult into string and returning it as Json - http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/ My problem is that I'm using Moq to mock the controller, and whenever I run unit test that uses this RenderPartialViewToString() method, I got the "Object reference...

MVC design question: recommended way to do a lookup to another controller's data from a view

Simply put: My model has two tables, Concepts and Transactions, which gives birth to two controllers of the same name. Transactions has a foreign key pointing to the primary key of Concepts (so you have a transaction like "$200 spent yesterday on concept 1", and concept "1" being "gas"). In the Transactions Index view, I want to show, in...

Asp.NET MVC is REST but Why Asp.NET WebForms are not?

Okay I hear that thing all the time on internet when reading an article about MVC : "Since Asp.NET MVC is REST, it is easy to consume ... etc." I've never heard such a thing for Asp.NET Webforms and it makes me wonder what makes something REST. As I understood, REST means Representational State Transfer in which what a user see on their...

Response.Cookies gets reset when RedirectToAction is called

IN my asp.net-mvc project I have an AccountController that upon logging in sets a cookie with user preferences to the Request.Response and then does a RedirectToAction. Upon redirecting, the cookies are reset so I loose my settings. The only solution I can come up with is adding the data from the cookie in the tempdata and then fetching...

Using a custom model binder for an argument of a controller action

I have a controller action that looks like: public ActionResult DoSomethingCool(int[] someIdNumbers) { ... } I would like to be able to use a custom model binder the create that array of IDs from a list of checkboxes on the client. Is there a way to bind to just that argument? Additionally, is there a way for a model binder to d...