asp.net-mvc

MVC2: Determine that redirect to login was due to forms authentication timeout?

What is the best way to detect when a redirect to the login page occurs due to a forms authentication timeout in order to display a meaningful message? <authentication mode="Forms"> <forms loginUrl="~/Login" timeout="15" slidingExpiration="true"/> </authentication> ...

asp.net mvc 1 validation using dynamically created controls

Hello there, Using ASP.Net MVC1 and am dynamically creating the html in a model that is then dropped into the view and rendered at run time. My view is a single page that looks like this: <%@ Page Language="VB" Inherits="System.Web.Mvc.ViewPage" %> <%=(ViewData("Content"))%> This dynamically created content is mostly dropdownlis...

How to generate a separated dll file for the code of a specific namespace

I have an asp.net mvc application, when I compile, it creates one dll file However, I have some code that I would like to re-use in other projects I guess I could create another project, then put this specific code inside it and it would generate a separated dll file. But is there another way to process in order to put the code of a sp...

ASP.NET MVC Expression is rendered "as is"

I have the following line: <link href="<%= Links.Content.Site_css %>" rel="stylesheet" type="text/css" /> which is rendered to <link href="Views/Shared/%3C%25=%20Links.Content.Site_css%20%25%3E" rel="stylesheet" type="text/css" /> So expression is not executed. If I remove quotes: <link href=<%= Links.Content.Site_css %> rel="styl...

Passing an nested arrays to asp.net mvc using jQuery's $.ajax

I am trying to pass a nested array to an asp.net mvc controller like this: var subgroups = []; subgroups [0] = [["A", "Y"], ["B", "Y"], ["C", "Y"]]; subgroups [1] = [["D", "Z"], ["E", "Z"], ["F", "Z"]]; $.ajax({ url: "<%= Url.Content("~/Controller/Action") %>", data: {...

MVC Route not working

Update: As someone pointed out I was missing an s in my Route registration. Now I have a secondary problem. This is how I want it to work: http://localhost/products/ --> ProductsController.Index() http://localhost/products/3/apples --> ProductsController.Details(int? id, string productName) This is what currently happens: http:...

Unit testing with EF4 "Code First" and Repository

I am attempting to get a handle on Unit testing a very simple ASP.NET MVC test app I've built using the Code First approach in the latest EF4 CTP. I'm not very experience with Unit testing / mocking etc. This is my Repository class: public class WeightTrackerRepository { public WeightTrackerRepository() { _context = ne...

Make an ASP.NET MVC application Web Farm Ready

What will be the most efficient way to make an ASP.NET MVC application web-farm ready. Most importantly sharing the current user's information (Context) and (not so important) cached objects such as look-up items (States, Street Types, counties etc.). I have heard of/read MemCache but haven't seen a simple applicable way (documentatio...

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? ...

MVC Ajax PartialViews not firing Javascript - should I use Spark?

Hi All, I'm using MVC 2 and the default view engine to return .ascx partial views using the JQuery Ajax .get() method. The partial views have some javascript in them and I'm finding that the behaviour of the javascript is erratic in that sometimes it executes, while other times it doesn't. I came across a reply from a MS Program Manager...

Grab data from table, join string from two columns, display in MVC selectList

Hi, I am new to MVC and LINQ. I have a table with three columns (id, text1, text2). What I want to do is generate a selectList in my view which has DataValue set to table.id, and DataText set to be = text1 + ", " + text2; (i.e. join text1 and text2 with comma separation). What do you reckon is the best way to achieve this? Cheers, ...

ASP.NET MVC and Ajax slow?

I've just started out trying MVC 2 and Ajax, and I'm wondering if I'm doing something wrong, because I was under the impression that Ajax would make changes in a webpage very fast. The example I have is with the Ajax actionlink: <div> <%: Ajax.ActionLink("Dita", "AjaxView", new AjaxOptions { UpdateTargetId = "myDiv" })%> </div> <div i...

Do WHERE clauses exist in Lucene(.Net)?

I'm building an ASP.NET MVC site where I want to use Lucene.Net for full-text search. My site will be divided into certain categories, and I want to allow users to search inside a specific category or inside all categories. To accomplish this, I plan to create a term in all documents in my index that contains the name of the category th...

Serving a file generated dynamically by the model, in ASP.NET MVC

Hi, I'm still new to web app development, so bear with me if this sounds a little silly. I have to implement functionality into an ASP.NET MVC2 website so that users can download an .rdp file that is generated after clicking a URL. The reason they need to be generated is that the user names for the machines are shared, but sometimes ...

ASP.NET MVC: ActionLink vs bare url

In ASP.NET MVC I see I have handy HTML helpers that I can use to construct form fields and any number of other little things. But then there's 'ActionLinks'. Why use an ActionLink instead of just writing the damn url myself in an HTML anchor tag? In other words, why would I use <%: Html.ActionLink("Back to List", "QuantityTypes") %>...

Accessing controller method from ResultExecutingContext in ASP.NET MVC site

I'm writing an attribute where I want to access a method on the class that the controller that has the attribute on one of its actions derives from. That's quite a mouthful, so let me explain: My controller derives from a class that has a method with the following signature: protected bool IsSearchEngine() (the base class itself derive...

create the authorize filter with parameter asp.net mvc

Hi Everyone, I have to develop an authorize filter in asp.net mvc.I have got five categories of users in my site and my site uses custom created authentication system.Now i have a controller action which should be accessible to 3 out of those five type of users.How to create a filter (basically authorize) and use it which fulfills my ...

asp.net mvc button jquery ui add popup

How can i add the jQuery UI popup to this button <%= Ajax.AjaxImageActionLink( "../../Content/images/add.png", "Change Password", "ChangePasswos", new { id = item.int_UserId }, new AjaxOptions { UpdateTargetId = "msgdiv" } )%> ...

meaning of "strongly typed view"

What is the meaning of "strongly typed view" in ASP.Net MVC. ...

MVC 2 EditorFor MaxLength and Size

How do you set the MaxLength and Size of a TextBox in MVC 2? There have been a couple of questions asked about this on SO. As a newcomer to MVC I am finding that none of the solutions appear to work - possibly because I am not doing it right. In any case I am wondering if there are better solutions since the previous questions appear to...