asp.net-mvc

[Authorize(Roles="whatever")] attribute for .net MVC controller action method

Essentially I want to show a friendly message when someone is not part of a role listed in my attribute. Currently my application just spits the user back to the log in screen. I've read a few posts that talk about creating a custom attribute that just extends [AuthorizeAttribute], but I'm thinking there's got to be something out of th...

ASP.NET MVC - How to make code behave differently when running locally vs. in QA vs. in Production

Question: How to make code behave differently when running locally vs. in QA vs. in production? Example: In an ASP.NET MVC application I have a controller set up to deliver e-mail notifications. When running locally on a development machine I want the e-mails delivered to the developer, when in QA I don't want any e-mail notifications ...

Creating and Updating many to many relationships in C# asp.net MVC with Linq2Sql

I have created a web app in MVC following the NerdDinner tutorial. I have 2 fields that have many to many relationship with my "dinner". For each "dinner", I need to be able to select one or more Companies from a Company table and one or more Services from a Service table. I've been reading blogs and forums for 2 days, but can't seem ...

AutoMapper custom type converter dependencies

I am trying to implement Automapper to map a ViewModel to an Entity where one of the properties of the Entity is also an Entity. I want my converter to use NHibernate's ISession.Load<> method to load this. So the question is what is the best way of injecting ISession into my ITypeConverter implementation? Also one thing to keep in mind...

c# hide Attribute in derived Class

Hi, I have a base class with an attribute and I want to hide it in a derived class. Is there any way to do this other than using reflection? [Authorize(Roles = "User,Admin,Customs")] public abstract class ApplicationController : Controller { } // hide the Authorize attribute public class ErrorController : ApplicationController { } ...

How to upload a file through jquery?

Hi I am wondering how would I do this with like jquery ajax. Right now I have a jquery ui dialog box popup and it has an html input file on it. Now when the user clicks import I want to do an ajax post to the server with jquery. I am not sure how to pass the file in though to my action view. Right now I have it doing a full post bac...

Suggestions for Structure of an ASP.NET MVC Application

I am a Java Developer making the transition to the C# world. I've gotten a pretty good handle on ASP.NET MVC (and can compare/contrast it to the concepts I learned for Struts). However, I'm looking for advice on how to structure my project. Currently, I have two solutions in the project: the MVC Web Application and a ClassLibrary sectio...

SharpArchitecture - FluentNHibernate Schema Generation?

Hello. I'm trying out SharpArchitecture and want to have FluentNHibernate generate my database schema for my MVC WebSite. I'm a bit lost on where to do this. I can do it by adding the SchemaUpdate thingy in the global.asax.cs-file right after NHibernateInitializer.Instance().InitializeNHibernateOnce(InitializeNHibernateSession); in "Ap...

Dynamically Add Elements to jQuery Sortable

This should be my last question on Jquery Sortable...for a while :) I have a list that I'm able to remove elements from dynamically. when users click the X close box on the element, I get the parent (the element itself) and remove it: function DeleteLink() { var jItem = $(this).parent(); var LinkId = jItem[0].chil...

Safe way to Store Credit Card Info Across Pages ASP.NET MVC

Hello, I'm running ASP.NET MVC and need a safe way to store credit-card data temporarily (I have a order confirmation page, which posts to an action that actually processes the order). I tried TempData, but it doesn't survive the post. Can I safely use session since it's stored on the server? Thanks. ...

Why doesn't c# support an object with an interface as a parameter?

I have the following class declaration: public class EntityTag : BaseEntity, ITaggable I have an Html helper method: public static string TagCloud(this HtmlHelper html, IQueryable<ITaggable> taggables, int numberOfStyleVariations, string divId) This is my ASP.NET MVC ascx: <%@ Control Language="C#" Inherits="System.Web.Mvc.View...

ASP.NET Application Webcam Capture

Ok, so I have seen a ton of stuff on capturing an image from a web cam but I want to capture video. I want to be able to control quality, length and size of file that will be transferred. It is part of an ASP.NET MVC C# web application and would appreciate any guidance in finding info on this topic, as well as any comments on efficiency...

MVC - How best to organize commonly used drop-down lists in many views

I am trying to understand how best to organize some common Dropdown lists used in several views (some are cascading) Is it best to create a single \Models\CommonQueries then create a webservice for each dropdown used in cascading situation then have a single controller that contains actions for each dropdowns This way I can follow DR...

mvc sample code to read the id of the selected checkbox

Is there any sample code of how to read the id of the selected checkbox in a view from a controller. <% foreach (var item in Model.projects) { %> <tr><td><input type="checkbox" name="selectedObjects" value=" <%=item.ID %>"> <%=item.Name %> <% } %> What must be the code on the controller to get the ID of the selected che...

Using MvcContrib Grid with dictionaries and lists

I have a class that contains a property-value (property bag) dictionary beside normal properties. I'd like to display a collection of this object in a table using the grid from MvcContrib. The class: public class ObjectWithPropertyBag { public string Property1 { get; set; } public string Property2 { get; set; } public Dic...

ASP.NET MVC Actions + Extension

i want have mvc actions plus file extension like /Home/Index.aspx which route to Index action of Home Controller. can everybody help me. have everybody any opinion or guideline? ...

JQuery Post to MVC method session variables dissapear

Hi, I'm writing an ASP.Net MVC application using Jquery to post some data to my users session. A user 1st accesses my site's page and then I have a button which performs a post using JQuery to an MVC controller method to store some data into the users session. When the initial page loads I create a session object for my user using a se...

asp.net mvc: pass information between 2 controllers to the view

Hi, hope i can explain myself... i have a login control in the masterpage. when you click the login button you go to the accountcontroller's logon method which checks your credentials. whether it is ok or not, you will be redirected to the homepage with a redirecttoaction("home","index"). but, in case login failed, i want to show a mess...

Pitfalls in using Silverlight for a spreadsheet-type web application module?

This question contains a lot of background information, to make sure you fully understand why we are looking at these technologies. The question is basically this: For a large, spreadsheet-type, module that we need to develop for our webmodule for our application, are there any pitfalls we should know about if we decide to use Silve...

Why should I go for ASP.Net MVC?

I have added this question as to know the different views why people are using ASP.Net MVC, please don't down vote. I know that it is RESTful, could you please put in more details to help me. I have checked few blogs but no good answers. I mean which drive me to get my ASP.Net website to ASP.Net MVC. ...