asp.net-mvc

How to list the existing action Controller dynamically from within master page?

I want to list all the existing controllers from within master page. For example: In my Controller folder I have: HomeController with actions Index, etc... ProductController with actions Index, Details, etc... ServiceController with actions Index, Edit, etc... SomethingController with actions Index, Update, etc... etc From withi...

What's a good HTML naming convention for model binding complex nested types?

If I have an object that is composed of nested complex types, e.g. a ViewModel that has a List<Fu> and a List<Bar> public class WarViewModel { List<Fu> Fu { get; set; } List<Bar> Bar { get; set; } } public class Fu { public int Id {get;set;} public Soldier Private { get; set; } } public class Bar { public int Id {g...

ASP.NET MVC Use Controller or View outside of the MVC application context

Hello i am creating a small webpage that give our users an interface to search in our database. This website must supply 2 webservice functions, Search(string searchString) and GetAccountInfoByInitials(string initials) I would like to use my controllers to do this, but i can not find out how i can get the html out of a ViewResult. I h...

getting images out of mssql in C# using streams

Hi there. I have a database which stores .png images as the sql "image" type. I have some code which retrieves these images as a byte[], and sends them to the page via the FileContentResult object in .Net. Performance is key in this application, and the images have to be retrieved and displayed as quickly as possible. My question is, can...

MVC How do I refresh a grid from a dropdownlist?

When I change the year in my dropdownlist, how do I refresh the grid underneath? <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AdminAccounts.master" Inherits="System.Web.Mvc.ViewPage<SHP.WebUI.Models.BankHolidayViewModel>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> BankHoliday...

ASP.NET MVC 2 Dropdown issue

Hi there, I am using MVC 2 and entity framework 4. On my create application page I have a drop down list which I populated with values from my AccountType enum. This is how I did it: public ActionResult Create() { // Get the account types from the account types enum var accountTypes = from AccountType at ...

Any ideas how to troubleshoot HTTP Error 400 for MVC/Firefox?

Two clients complains on HTTP Error 400 from Mozilla Firefox 3.6.9. This happens when they open any link - both mvc application and also any static images, which are hosted on Classic application pool without any code. Exact error message is HTTP Error 400. The request is badly formed No errors in windows log and application error log....

Base page in MVC 2

Hi, I have just moved over to using ASP.NET MVC 2. In web forms, I normally had a BasePage class that extends from System.Web.UI.Page. And then every page extends from this BasePage. In this BasePage class I have methods that I need. How would I do this in an MVC application? Any samples would be appreciated. Thanks. ...

suggestions for Membership in ASP.NET MVC application

With this question I am mostly looking for answers from people that have implemented the out-of-the-box ASP.NET membership in their own database - I've set up the tables inside my database and as far as I can see they contain mostly what I need but not everything. I will have the notion of a Firm (Company) to which Users will belong so I...

Redirect to Error page in mvc

I working in mvc 2 and need to redirect on error page with exception mesage. For this I have i have override OnException () action of controller and trying to do like " View("Error").ExecuteResult(this.ControllerContext);" but it is throwig exception 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper" please give me the r...

Do search engine robots read localized text from resource files?

In my asp.net mvc project all text is in resource files, and in view for text values roots to the resource file. I have english and german text. Current culture is read from cookies and rooted from global.asax. Will this work correctly with search robots or is it better to have an additional parameter value like /en/ in my url? ...

How to save dynamicly created template in database?

I would like to enable users to create their own templates in my asp.net mvc web application. For example, you would create a simple template like a log on control, 2 labels, 2 textboxes, and 1 submit button. Is it possible to allow users to save such templates in a database and then use them/extend them later? Could you please give m...

ASP.NET MVC Create querystring from form

I am trying to create a simple search box that results in something like http://www.example.com/Search?s=searchTerm I have the routing setup so that it accepts a url like this, and does the right thing. The problem I'm having is getting the form to create the querystring. I have tried many variations of: <% using (Html.BeginForm("Sear...

MVC datepicker in a grid

I am using the following EditorTemplate which ensure the datepicker is enabled for date fields; <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <%:Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "datePicker" }) %> However the date is in the partial view following...

MVC Problems setting the selected item of the dropdownlist

In my controller I set the SelectedYear field as follows; [Authorize(Roles = "Administrator, AdminAccounts")] public ActionResult BankHoliday(int? id) { BankHolidayViewModel BankHolidayViewModel = new BankHolidayViewModel(); int year = DateTime.Now.Year; if (id.HasValue) yea...

ASP.Net MVC - Displaying text with newlines in

I have some text, stored in a table. I'm using asp.net mvc to display this. One of my views, has the following: <%=(Model.QuestionBody.Replace("\r\n", "<br/>").Replace ("\r", "<br/>")) %> Like this, it displays correctly However, if I omit the .Replace, it displays all on one line. The same data displayed in a TextBox however, displ...

Where can I find some quality tutorials that take me through the anatomy of an MVC view?

My background is mostly in desktop applications on the Microsoft platform. I've been working a lot with ASP.Net MVC lately and completely skipped over learning webforms. I find I'm having the most trouble (not being a web guy) with writing my views in MVC. How proficient should I be with HTML and javascript to write good views in MVC?...

How to generate ActionLink inside Threads

I've got a thread that sends emails around. I need to generate ActionLinks as part of the content of the email so the user can click on the link and be redirected to the website, exactly to the required page. I tried to instantiate a UrlHelper class and use it's Action method to generate the link but since threads don't run within the co...

Using a MemoryStream with FileStreamResult possible?

I'm using DotNetZip to create a zip file and pass it to a FileResult. On debug, I can verify that the MemoryStream contains a file, but when I run it through FileStreamResult, it returns 0bytes: public FileResult GetZipFiles(int documentId) { var file = fileRepository.Get(documentId); var zip = new ZipFile(); var st...

Validation propagating to related objects

I have a model like this: public class Person { public int ID { get; set; } [Required(ErrorMessage="Name cant be empty")] public string Name { get; set; } public Person Friend { get; set; } } I want to create a new Person, and made a form with the fields using the strongly typed HtmlHelper ID Name Frien...