asp.net-mvc

ASP.NET Subdomain Cookie (parent and one subdomain)

Hi. I have an app with multiple subdomains, subone.parent.com, subtwo.parent.com. I have a logon page at parent.com/login. When a user logs in I redirect them to the proper domain based on which one they are a member of. This works fine. FormsAuthenticationTicket ticket = new FormsAuth... string encTicket = FormsAuthentication.Encry...

retrieve route values from RouteTable

hi, i want retrieve route values from RouteTable, but it's null. can anybody help? public static class GetRouteValues { public static string GetSomeValue() { RouteCollection routes = RouteTable.Routes; var value = routes["somevalue"].ToString(); return value; } } i want retrieve this value for using...

ASP.NET MVC - Post works on dev machine, but not on live

I have an edit page I want to use to allow editing of user details. When I update some user details and post on my dev machine it works as expected, details are saved to the DB and I am re-directed to the details page which displays the updated information. When I publish the site to the live server and perform the same actions it basi...

Database error ASP.NET

I have my projects setup as follows (repository pattern): myProj.Data (Contains the xDB.mdf) [Library] myProj.Service (Uses myProj.Data) [Library] myProj.WebApp (Uses myProj.Service) [ASP.NET Website] In 1. I access my Database via Linq to Sql. The app.config looks like this: <add name="XDbConnectionString" connectionString="Data So...

LINQ, repository pattern and many-to-many relations

Hello, I've a problem with saving changes to database, I'm using LINQ2SQL mapping. I've implemented M:M relation (User <= UserRole => Role) based on tutorial: http://www.codeproject.com/KB/linq/linqtutorial2.aspx#premain25 Everything works fine when I'm using one class which is inherits from DataContext and is responsible for all of m...

Populate a DropDown/Select based on the value chosen on another DropDown

Hello folks, I'm a beginner developer but I stumbled across a case I can't solve. I'm using ASP.NET MVC with C# plus some javascript (JQuery, JSON...). What I have to do is to populate a dropdown based on the value chosen in other. It seems simple (and I know it is) but this particular case is eluding me. I've lost many hours and I'm st...

Issue with ModelBinding in ASP.NET MVC

Methods from my controller class public RedirectToRouteResult AddToCart(Cart cart, int productID, string returnUrl) { Product product = productsRepository.Products.FirstOrDefault(p => p.ProductID == productID); cart.AddItem(product, 1); return RedirectToAction("Index", new { r...

How to make ASP.NET Routing escape route values?

I have an ASP.NET MVC site where I want routes like /{controller}/{id}/{action}/{date}, where "date" is the mm/dd/yyyy portion of a date/time. (I'm dealing with time-dimensioned data, so I need both an ID and a point in time to do most operations) The route for this is simple: routes.MapRoute( "TimeDimensionedRoute", "{controll...

What can cause the Model Binding to fail in ASP.NET MVC 1.0?

Here is my class...any pointers? public class Cart { private List<CartLine> lines = new List<CartLine>(); public IList<CartLine> Lines { get { return lines.AsReadOnly(); } } public void AddItem(Product product, int quantity) { var line = lines.FirstOrDefault(l => l.Product.ProductID == product.ProductID); ...

Selective client side validation in ASP.NET MVC

How can I implement selective client side validation using MVC 2 built-in validation system? Assume I have a checkbox in my form title "Do you have any child?" and if checked the textbox below it should be required (textbox titled Number of children). ...

ASP.NET MVC Authorize Attribute to launch a modal?

I am working on a site that makes use of jquery modal dialogs to do various things like logging in and such. However; we have one slight issue with the use of these.. which is we are using the [Authorize] attribute on a lot of our action methods and so what is happening is if the user is not logged in and hits a route that they need to ...

ASP.NET MVC 2 area namespace assignment

Suppose the root project has My.Root.Project namespace. I wonder what namespace should be assigned to an area classes? Possible alternatives: My.Root.Project.Areas.Area1 My.Root.Project.Area1 Esthetically, I prefer second one. However, since I use a single-project areas, all the classes created within Areas\Area1\... folder are given...

How to add page title in url in asp.net mvc? (url generation)

How to dynamically create urls/links like: www.restaurant.com/restaurant/restaurant-name-without-some-characters-like-space-coma-etc/132 what are the keywords i can use to google some articles on this topic? (how to genererate and handle this kind of urls inside asp.net mvc) There are some questions: How to generate links? (store slugs...

Whats the point for IRepository?

Whats the point of it? It just add more code that you need to write, which doesnt really do anything to an app that it couldnt do before adding a IRepository ...

Visaul studio closes unexpectedly

I am doing an MVC project... am very new to MVC... something very strange is happening... When i drop a control from the toolbox to the design page visual studio closes.. i have no clue why this happens.. am totally perplexed...i tried searching for possible solution in the net...nothing showed up...:( thanks in advance... ...

If User.IsInRole with string array?

Hello Im tryint ot build a custom validation where I check if the user contains in a role. And I'm having problems with string array, what is best way to check if it contains a specific value? public string[] AuthRoles { get; set; } public override void OnActionExecuting(ActionExecutingContext filterContext) { if...

DropDownList in MVC?

Hello All, I am having a dropdownlist in my appliaction which I have binded through the database records but on any of the edit form I want to set the selected index of the dropdown list how shall I do that ,I am Pastng my code here. Code for binding the dropdownlist public IList GetFeedbackList() { int feedbackId = 0; string feed...

Asp.net mvc 301 redirect from www.domain.com to domain.com

We have a website at domain.com, which is also accessible via a CNAME entry for www.domain.com that points back to domain.com. We'd like all visitors to www.domain.com to be redirected to domain.com using a 301 redirect. What's the best way to implement this in asp.net mvc? In global.asax? ...

MVC last chance to change response before it is rendered to user

I need to change full html response stream (with html parsing) before it is rendered to user. Where/When is the last chance to do that? ...

ASP.NET MVC actions with optional params

I have an MVC action on my abstract BaseControlller like this (and this action is common across all inheriting controllers): // // GET: /controller/RenderForm/{formType} [Authorize(Roles = "Administrators")] public ActionResult RenderForm(FormType formType, BaseContentObject contentObject) { string constructP...