asp.net-mvc

ASP.Net MVC Memberships

I want to use the the AuthorizeAttribute to control which users are allowed access to my actions. I just want to clarify that my logic is in order. I create my own implementation of IPrincipal I post a user's credentials to a login action of a security controller. I validate the credentials with a UserService class and assign the IPri...

ASP.NET MVC Model Binding

I was wondering if there was a way to bind the value of an input field straight to the property in the Model through a strongly typed model. For example, let's say my Model is an Address object. I want to be able to say Html.Textbox(Model.Address1.State, "state", Model.Address1.State). So the first parameter would be the explicit prop...

requireSsl mvc attribute : working with returlUrl

I have [requireSsl] on my accounts controller. It appears to work for all actions except the login action. I believe this is because the login action is called as follws: new { controller = "Account", returnUrl = HttpContext.Current.Request.RawUrl } Account/Login?returnUrl... Account/Login%3freturnUrl... when changing to http...

Can I get a simple bool value from another controller in my HomeController?

I have a check for registration in my RegistrationController: public class RegistrationController : Controller { private readonly IAmARegistrationRepository _RegistrationRepository; public RegistrationController(IAmARegistrationRepository registrationRepository) { _RegistrationRepository = registrationRepository; } public bool I...

Upgrade to ASP.NET MVC version 2

I have been doing some work on a ASP.NET MVC project today i tried to publish the website but i ve got an error. my hosting service provider told me is due to the fact that i have version 1 while they support version 2. how can i upgrade to version 2? are the differences between the two version so extreme that a previous version is not s...

ASP.NET MVC: putting custom attributes into option tag in select list

I'm using ASP.NET MVC, and am trying to render a select list with the HtmlHelper.DropDownListFor method, like so: <%= Html.DropDownListFor(x => x.AllTopics, SelectListHelper.GetSelectListItems(Model.AllTopics), "Select a Topic", new { id = "allTopics", @class = "topic-dropdown" })%> where SelectListHelper just returns an IList<SelectL...

ASP.NET MVC ModelBinding Inherited Classes

I've got a question about ModelBinding in ASP.NET MVC (I'm using MVC 2 preview 2) related to inheritance. Say I have the following interfaces/classes: interface IBase class Base : IBase interface IChild class Child: Base, IChild And I have a custom model binder BaseModelBinder. The following work fine: ModelBinders.Binders[typeof(C...

How do I get Absolute Root Links in ASP.NET MVC 2.0 beta Areas?

The link for logging in looks like this: <%= Html.ActionLink("Log On", "LogOn", "Account") %> which yields the following link in the browser: http://localhost:2300/Account/LogOn However, if I switch to an Area, such as Content, the Login link now looks like this: http://localhost:2300/Content/Account/LogOn ...which fails of cour...

ASP.NET MVC Ajax and the CKEditor

I am working with MVC 1, and the CKEditor. I am integrating ajax forms which work great, but the editor window disappears after the ajax post. In webforms, I would have to not use ajax, or use a postback trigger. Is there a way to reload the editor on the ajax submission? Any help is appreciated. ...

Catch all routes not working using regular expression

I know that the first route will catch most of the paths. However, this will catch also /Product/Edit/blablabla (i'm using ASP.NET Routing Debugger): public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", ...

Dynamically retrievng UserControl's Virtual Path

I have an application with the FrontEnd separated into one Project file and the Codebehind/classes separated into a completely different class library. What I need is a way to, from the UserControl Type, obtain it's VirtualPath. Typically, we would have this in code Board uc = (Board)Page.LoadControl(@"~\Board.ascx"); But I want is s...

Need advice for building a search in an ASP.NET MVC application.

I've been googling but haven't found any good info on building a good search function in a ASP.NET MVC project. Off the top of my head, a search feature for searching authors and books would look like this: char[] delimiterChars = { ' ', ','}; string[] searchterms = SearchBox.Split(delimiterChars); IQueryable<SearchResult> SR = _db.Boo...

log in asp.net mvc

In my mvc application i need to check a condition in action and throw it to the log. How can i add a info to log info. ...

In MS MVC, are Poco classes to be defined in the Models namespace but outside of a repository class?

I think I am very close to assembling an MVC repository correctly but just falling apart at the fringe. I created an MVC project with a repository and am returning data successfully, but not accurately as it pertains to DDD. Please tell me where I am incorrect in terms of strict DDD assembly. I guess if the topics are too wide, a book...

How do I create a selective Windows Authorise in ASP.Net MVC

I want to use Windows authentication within an MVC app, but only for certain areas of the site (i.e. admin area). Currently I've set in the web.config; but unlike the Forms one this seems to force authentication on the whole application even though the controlers don't contain the [Authorize] filter. Is this feature built in or will I...

WebForms view engine looks ugly, any way to beautify it?

When I look at an MVC view which I wrote, it all looks like tag spaghetti to me especially with default color scheme of VS 2008. It's all <% yellow tags %> everywhere. It's really hard to distinguish server and client side code. In classic ASP it wasn't that bad because usually server-side code blocks weren't as interleaved as lightwei...

Getting app root in MVC controller constructor

I need to grab the physical path to the app root in an MVC project; I use this to serve from a repository that places its items on the file system. Alternative, I could use Dependency Injection, but I'd have the same problem; I don't have a Request until someone calls an action, so I can't use Request.PhysicalApplicationPath. ...

Generic object controller in MVC, can you improve my code ?

I am creating an application that will display a list of objects in a datagrid (list of any type of object), and allow the user to update any item. The code will know nothing about the object being displayed until runtime. Can you improve my code for the update? I am using Formcollection to get items from the form and creating an instanc...

ASP.net MVC how to get the value of the ID field for the list of items?

I have an application, that shows list of items bound to a typed model. In the list every item has an ID from a lookup table. How to show the value of the lookup data for each item instead of IDs? The best way has to link a html dropdownlist to each ID, from where I would be able to choose the appropriate value. Thanks in advance G...

Datatables plugin

Is there any tutorial of how to use DataTables plugin with asp.net mvc(especially server side code)? Thanks ...