asp.net-mvc

DataAnnotation attributes buddy class strangeness - ASP.NET MVC

Given this POCO class that was automatically generated by an EntityFramework T4 template (has not and can not be manually edited in any way): public partial class Customer { [Required] [StringLength(20, ErrorMessage = "Customer Number - Please enter no more than 20 characters.")] [DisplayName("Customer Number")] public v...

How can i allow the user to point their custom domains to sub domains in my asp.net MVCapplication? [As seesn in Posterous.com]

I am looking for a posterous like custom domain management for the users. The user can register a domain and should be able to point their new domain to their sub domain in the web application. Any ideas?. NOTE: I am not looking for a serverfault.com like answer but a programatic one as it is done in posterous.com. ...

MVC Checkbox List

I just wrote perhaps the ugliest bit of MVC code in existence. It is: <table> <tr> <% int i = 0; foreach(Thyla.Models.Tag tag in this.Model) { i += 1; %> <td> <span> <input type="checkbox" name="TagSelector" id='<%= tag.TagName%>' value='<%= tag.TagName%>' /> <label for="<%= tag.TagName%>" title="<%= ta...

How do I get the action name from a base controller?

Hi, I'd like to implement a base controller on one of my controllers. Within that base controller, I'd like to be able to get the current executing ActionResult name. How would I go about doing this? public class HomeController : ControllerBase { public ActionResult Index() { And; public class ControllerBase : Controller { ...

ASP.NET MVC Route based on Web Browser/Device (e.g. iPhone)

Is it possible, from within ASP.NET MVC, to route to different controllers or actions based on the accessing device/browser? I'm thinking of setting up alternative actions and views for some parts of my website in case it is accessed from the iPhone, to optimize display and functionality of it. I don't want to create a completely separ...

how to dynamically add textbox in asp.net mvc

how to dynamically add and remove textbox in asp.net mvc ...

ASP.net page gets error on import statement, but I do have the reference in place?

Hi, Any ideas why I am getting the below error in my MVC2 project, even through in the project itself I definitely have a reference to "system.Web.Entity"? Compiler Error Message: CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) Source Error: Line 1: ...

log traffic (including posted data) IIS 6.0 - windows server 2003

Hi, I understand that IIS logs parts of http request which I can access. I would like to log the whole http request for a short period of time. This means I would like to store the data being posted in its raw form. Is this possible using ISS’s logging facility or do I have to install another tool? I have the following problem. I expos...

Read cookies in silverlight

hi, I have an ASP.NET MVC application. In this after user get Sign in .We set the a cookie for the user who logged in using FormsAuthentication.SetAuthCookie(userName, false). In other page we get the Cookies using the FormsAuthentication.GetAuthCookie(userName]) . This cookie values as string is then set in the Response.Cookies["use...

Windows Azure ASP.NET MVC Role behaves strangely when redirecting from HTTP to HTTPS

Subj. I've got an ASP.NET 2 MVC Worker Role Application, that does not differ much from the default template. When attempting redirect from HTTP to HTTPS (this happens when we access constroller secured by the usual RequireSSL attribute implementation) we get blank page with "Bad Request" message. IntelliTrace shows this: Thrown: ...

routing difficulty

Part of my application maps resources stored in a number of locations onto web URLs like this: http://servername/Issue.aspx/Details?issueID=1504/productId=2345 Is it possible to construct an MVC route that matches this so that I get the path in its entirety passed into my controller? Either as a single string or possibly as an params s...

Best way to pass navigation / link information from controller to view?

In an ASP.NET MVC app I have a page with a dynamically generated list of links to different pages in the app. What is the best way for the controller to pass the link information to the view? I want to keep the view as simple as possible and I'm assuming it's wrong to generate URLs in the controller (too UI specific, makes unit testing ...

Routing fails when only category is supplied

My website uses categories and sub-categories. I'd like the follow mapping: /Category/Fruit /Category/Fruit/Apples But if I use the below: routes.MapRoute( "Category", // Route name "Category/{category}/{subcategory}", // URL with parameters new { controller = "Entity", action = "Category" } /...

Beginner MVC question - Correct approach to render out a List and details?

I'm trying to set up a page where I display a list of items and the details of the selected item. I have it working but wonder whether I have followed the correct approach. I'll use customers as an example I have set the aspx page to inherit from an IEnumerable of Customers. This seems to be the standard approach to display the list ...

asp.net mvc - Check what controller and method are called?

How to check what controller and method are called? In html in body tag there is: <body id="somethingThatDependsOnControllerAndMethod">. id value will be assigned based on controller and it's method. ...

Create a T4MVC ActionLink with hash/pound sign)

Is there a way to create a strongly typed T4MVC ActionLink with a hash in it? For example, here is the link I'd like to create: <a href="/Home/Index#food">Feed me</a> But there's no extension to the T4MVC object that can do this. <%= Html.ActionLink("Feed me", T4MVC.Home.Index()) %> So, what I end up having to do is create an acti...

Migrating web.config files to new versions of framework

So far I've migrated two ASP.NET MVC 1 solutions to MVC 2 and therefore kept my web.config almost the same, just changed the necessary stuff in it as documented in Release notes. Although I created a few new test MVC 2 webapss from scratch, until now I haven't really checked out the default new web.config. As I created a new empty MVC 2...

How to create anonymous objects of type IQueryable using LINQ

Hi, I'm working in an ASP.NET MVC project where I have created a two LinqToSQL classes. I have also created a repository class for the models and I've implemented some methods like LIST, ADD, SAVE in that class which serves the controller with data. Now in one of the repository classes I have pulled some data with LINQ joins like this. ...

How to find the Checked Status of All Checkboxes

Here is my problem. I have a list of models that are displayed to the user. On the left is a checkbox for each model to indicate that the user wants to choose this model (in this case, we're building products a user can add to their shopping cart). The model has no concept of being chosen...it strictly has information about the produc...

How can I request local pages in the background of an ASP.NET MVC app?

My ASP.NET MVC app needs to run a set of tasks at startup and in the background at a regular interval. I have implemented each task as a controller action and listed the app-relative path to the action in the database. I implemented a TaskRunner process that gets the urls from the database and requests each one at a regular interval usin...