asp.net-mvc-2

Why is VS2010 in ASP.NET MVC2 giving me the wrong JQuery intellisense?

In ASP.NET MVC'S JQuery intelligence I am getting methods such as "constructor", "toString", etc. What do I have to do so that I get JQuery methods such as "css" and "click"? If I just rightclick on a plain .htm file and open up Visual Studio, it works out-of-the-box: ...

Unit testing - can't move from theory to practice

It seems like every unit test example I've encountered is incredibly obvious and canned. Things like assert that x + 3 == 8, and whatnot. I just have a hard time seeing how I'd unit test real world things, like SQL queries, or if a regEx used for form validation is actually working properly. Case in point: I'm working on two ASP.NET M...

HtmlTextBoxFor Loop in MVC 2 C#

I am trying to do something that I think is relatively simple but can't get it to work and would be greatful for some pointers. I've got a form with a list of text boxes in it... Lets say, I want to find out "Your Favourite Pirates", and get you to list all ten on the page with comments as to why they are your favourite. So in my view...

MVC in C# coexisting with Webforms in VB. Can it happen?

I have inherited a really awful webforms application that is all kinds of bad--an untestable hairy mess of datasets and Page_Load events. Object oriented? N-tier? Unit tests? source control? All academic niceties to the team that built this mess. It started life as an asp classic app, got mostly ported to VB.NET. Management denied m...

In Multi-Tenant Data Architecture, what is the best way to implement tenant filter view?

I am implementing a SaaS application using ASP.Net MVC 2 and SQL Server database. I am using Shared Tenancy approach. To filter data, so far I have found 2 approaches. Option 1: http://msdn.microsoft.com/en-us/library/aa479086.aspx#mlttntda_tvf Using sql login per tenant. Thus, using SUSER_SID() as a filter in the views Option 2: ht...

How do I use DisplayFor() for objects that are not directly part of my model in asp .net mvc 2?

I'm sure I'm missing something pretty simple here. I've created a custom DateTime display template. This works fine when using: <%= Html.DisplayFor(x=>x.DateTimeProperty) %> However, I have a situation where I am iterating over objects in the Model in a for loop while inside a partial control. I want a DateTime property to use the dis...

How to concatenate several MvcHtmlString instances

I have some doubts about how to concatenate MvcHtmlString instances because of this information found in MSDN : MvcHtmlString Class Represents an HTML-encoded string that should not be encoded again Do I risk that strings are HTML-encoded twice when using code like this: var label = Html.LabelFor(model => model.Email); var textb...

Using a dash (-) in ASP.MVC parameters

<% using (Html.BeginForm("SubmitUserName")) { %> <input type='text' name='user-name' /> <input type='submit' value='Send' /> <% } %> What should be a signature of a corresponding Action method to accept user-name parameter? public ActionResult SubmitUserName(string user-name) {...} Method signature above does not work for so...

ASP MVC 2 Uploading file to database (blob)

Hi, I am trying to upload a file via a form and then save in in SQL as a blob. I already have my form working fine, my database is fully able to take the blob and I have a controller that take the file, saves it in a local directory: [AcceptVerbs(HttpVerbs.Post)] public ActionResult FileUpload(int id, HttpPostedFileBase uploadF...

ASP.NET MVC "The call is ambiguous" Error (System.IO.TextWriter.Write)

Hi everyone, I am creating a dynamic CSS file in ASP.NET MVC2, and I'm now encountering an exception. Everything was working fine, but all of a sudden I'm getting this error message for 2 variables: The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.Write(string, params object[])' and 'System.I...

How to fake Http post?

I am using asp.net mvc and I want to fake a http post to see what would happen. Is there any software that I can use? ...

"You must add a reference to assembly 'System.Data.Services.Client, Version=3.5.0.0'"

I'm building an app using Windows Azure Table. I've encapsulated all my calls to the Table Service into its own assembly. This assembly uses the .NET 4.0 Framework and includes a reference to System.Data.Service.Client (4.0). I'm able to use this assembly from a test project with no issue. When I add this project as a reference to an M...

Recursive Reflection of property values with LINQ?

I have a predicate builder that accepts a SearchInfo Class. For most cases this works great, but has problems if a user specifies a query on a property that has a deep object graph. For example, a list of possible properties: var names = new[] { "Action.Strategy.Objective.Goal.Identifier", "Action.Strategy.Objective.Identifier", "Actio...

Html.Hidden() inserting wrong value

When I use a form html helper method in one of my views like <%=Html.Hidden("id", "some id text") %> it creates a hidden input field for me but it puts the wrong value in there. Instead of getting <input name="id" type="hidden" value="some id text"/> I get <input name="id" type="hidden" value="11000"/> So the value is being found ...

MVC2 sending collections from the view a controller via json.

I've been looking on forums for 2 days now and can't find a good answer so I'll just post it. I appear to be having a problem posting JSON back to the controller to save. The JSON should map to model view but it keeps getting default(constructor)values rather then the values from the POST. We have a series of JS widgets that contain a...

Are singletons automatically persisted between requests in ASP.NET MVC?

I have a lookup table (LUT) of thousands integers that I use on a fair amount of requests to compute stuff based on what was fetched from database. If I simply create a standard singleton to hold the LUT, is it automatically persisted between requests or do I specifically need to push it to the Application state? If they are automatica...

What is ASP.NET MVC 2 way to to represent same model in two different ways

For instance I have a model X with properties Title(string) and Valid(bool). I need to show same model on two separate pages with different field labels and input controls. E.g. "Title" for title and "Valid" for valid on one form while "Destination" for title and "Returning" for valid on the other. I guess the easiest way would be to h...

JQuery.Ajax call to Asp.Net MVC JsonResult gives 12031 error, Json webservice works fine

I have the following 2 jQuery Ajax calls. The first is a call to a Asp.Net Json Webservice and always works. The second is a call to a ASP.Net MVC action that return an json result. This call always fails with Status=12031 the first time the page is loaded. The responseText is empty. After a refresh de second call usually works fine. jQ...

Need a good tutorial on asp.net MVC 2 Areas

Hey There Does anyone have some links on some really good tutorials on asp.net MVC Areas? I found a couple on google, but would like to see if anyone else dug up sommin great. ...

Resizing images on the fly, or storing different sizes on disk?

I'm building a Web application that will eventually contain a lot of images. These images will need to be displayed in different formats across the site. What would be the pros/cons of the two solutions: Storing various versions of the picture when they are uploaded (e.g. thumb, small, medium, large, verylarge) Resizing the image throu...