asp.net-mvc

How can I make actions work in the HomeController without typing "Home"?

My HomeController is controlling some pages like 'Index' and some others like 'Contact', 'About Us'. But, if I type: www.blabla.com/ the 'Index' will be called and it works. But, if I type: www.blabla.com/AboutUs it doesn't work at all! It just works if I type: www.blabla.com/Home/AboutUs How can I make all the actions in Home...

Do roles/views belong inside or outside of the Repository Pattern?

Does role / view logic belong inside or outside of the Repository Pattern? For example, I have a table of products, and each product has 5 price fields - one for each type of customer (wholesale, retail etc). I only want to show the appropriate price to the appropriate user. If I have a repository of these products, should the Product...

Controller equivalent of HttpContext.Current in ASP.NET MVC

I'd like to get access to the current executing Controller so I can offload the return of the appropriate ActionResult onto a helper method. To this end, I'm looking for the equivalent of what I would have thought would be ControllerContext.Current but isn't. Thanks! Edit for clarification: I've got a generic form control which is Jav...

How can I create 1 route with 2 differents user's access in ASP.NET MVC??

Hi everyone! How can I do this: I have on page named "Schedule" and it can be accessed through 2 differente ways: URL 1- www.bla.com/Admin/Schedule URL 2- www.bla.com/Schedule "URL 1" will be accessed by users with Admin previlegies and this View will show some Admin stuff, and users must be LoggedOn. In the otherhand, "URL 2" will ...

How do you place controllers and related views in separate folders in ASP.NET MVC

I would like to group all my Controllers with related Views in separate folders. How can I achieve this? ...

Jquery.Validate and MVC Framework

Alright this problem has been driving me a little crazy. I have a checkbox on my form that looks like this: <%=Html.CheckBox("Agreement", false)%>Yes, I agree to the terms And then I have a js file that is loaded into the browser after jquery and jquery.validate are loaded that looks like this: $.validator.setDefaults({ submitHandl...

Jquery onchange giving me fits.

I know I must be overlooking something. Here is my code, why is this not working: <label> Customer</label> <%= Html.DropDownList("CustCodes", (SelectList)ViewData["CustCodes"], "-- Select a Customer --", null) %> <script type="text/javascript"> $(document).ready(function() { $("select#CustCodes").bind("ch...

GetLocalResourceObject with NVelocity

How can I load a .resx file with GetLocalResourceObject when using NVelocity? I'm using ASP.NET MVC with mvccontrib nvelocity viewengine and sharp-architechture. I've hardcoded every possible virtualpath I could think of (eg. ~/Home/index.vm.resx) but everyone fails. I've also tried with ExpressionBuilderContext. ...

How return 304 status with FileResult in ASP.NET MVC RC1

As you may know we have got a new ActionResult called FileResult in RC1 version of ASP.NET MVC. Using that, your action methods can return image to browser dynamically. Something like this: public ActionResult DisplayPhoto(int id) { Photo photo = GetPhotoFromDatabase(id); return File(photo.Content, photo.ContentType); } In the ...

ASP.Net MVC RedirectToAction with anchor

Hi, I have the following problem: For example I have route like this: routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler()) Defaults = new RouteValueDictionary( new { controller = "Thread", action ="ShowThreadLastPostPage"}), Constrain...

does an MVC Action have to return an actionResult?

Can a so called action in my controller just be a regular function that returns anything I want or does the return of an ActionResult declare whether its an "action" or not? I was wondering if i could call functions in my ActionLink in the "actionname" that didn't return actionresults. thx ...

ASP.NET MVC Contrib Projects

I am looking to get on with contributors on an ASP.NET MVC Project. I am professionally developing for a large firm and don't get enough of it here. I also teach Java Object Oriented practices at a University, and still don't feel that I get enough of the engineering with this. Simply put, I am looking to get onto a project (small, op...

How should I implement localization with ASP.NET MVC routes?

I'm trying to plan for future (months away) localization of a new ASP.NET MVC site. Trying to decide what makes most sense to do, as far as constructing the URLs and routing. For instance should I start off immediately with this : http://www.example.com/en/Products/1001 http://www.example.com/es/Products/1001 or just http://www....

What's the best place to put default content in an MVC application?

I'm working on a sort of a CMS/Wiki application to help me experiment with the new Asp.Net MVC framework, and I'm trying to wrap my head around some of the code organization. Right now, I have three views that cover displaying an article: Index, Edit, and Rename. All three views display the contents of the current page, or placeholder ...

Uploading multiple images + text fields in ASP.NET MVC

I'm very new to ASP.net MVC, so please be as descriptive as possible in your answer :) Let me simplify what I'm trying to do. Imagine I have a form where you want to enter some information about a car. The fields might be: Make, Model, Year, Image1, Image2. On the bottom of the form is a "Save" button. The associated Controller meth...

ASP.Net MVC ActionLink's and Shared Hosting Aliased Domains

So, I've read this and I've got a similar issue: I have a shared hosting account (with GoDaddy, though that's not exactly relevant, I believe) and I've got an MVC (RC1) site deployed to a sub-folder which where I have another domain name mapped (or aliased). The sub-folder is also setup as an application root as well. The site works w...

Where to put view-specific javascript files in an ASP.NET MVC application?

What is the best place (which folder, etc) to put view-specific javascript files in an ASP.NET MVC application? To keep my project organized, I'd really love to be able to put them side-by-side with the view's .aspx files, but I haven't found a good way to reference them when doing that without exposing the ~/Views/Action/ folder stru...

How do you unit test a custom WebFormView since it calls out to the BuildManager class?

I'm trying to write up a custom WebFormView to help with skinning a website I'm working on. The code is loosely based on how it's done in Oxite. The problem I'm having right now though is I'm not sure how I would unit test the Render method since it has a call to the BuildManager. There are no unit tests for this code in the Oxite proje...

Have asp.net-mvc generated urls in included javascript file?

My asp.net-mvc view has an included javascript file. This javascript file has the following line: $("input[id='SearchBag.CompanyName']").autocomplete("Search.mvc/AutoComplete/"); This works. Great. But it would be even better if I could replace the autocomplete's path with a generated URL so if I change the routing paths, I won't have...

ASP.NET MVC Unhandled Exceptions on Images?

I haven't been able to replicate the exception when I browse my site... but I found out about this through my event logger (it emails my cell phone when an unhandled exception occurs). Here's the exception: The controller for path '/Content/UsrImg/ImageFileName.jpg' could not be found or it does not implement IController. Wh...