asp.net-mvc

Supressing form post on enter when a textbox is empty

I am using MVC, not that this makes a difference, but I have a text box for searching. <% using (Html.BeginForm("Index", "Search", FormMethod.Post)) { %> <%= Html.AntiForgeryToken() %> <div id="search_box"> <span id="search-title">Search Site</span> <div> <%= Html.T...

ASP.NET MVC url search parameter without question mark

I have a route defined as: routes.MapRoute("AllUsers", "Users/Search/{Search}", new { Controller = "Users", action= "Index"}); and the form as: <% using (Html.BeginForm("Index", "Users/Search/", new { RouteValue = "AllUsers" }, FormMethod.Get, new { id = "searchForm" })){%> <input id="searchBox" name="search" type="text...

What is a way to do a Generic Repository with Entity Framework 4.0 where I have function imports? (I don't want just a generic "execute" function where I pass in strings for the function name and parameters)

I have a generic repository that I communicate with my object context with. My object context has function imports that I want to be able to call through my generic repository. Currently I call them through an "Execute" function, but this is not ideal because I have to pass in my function name and parameters as strings which can cause r...

Using NerdDinner as base reference, how to perform data access tasks in controller?

I am trying to follow the Nerd Dinner MVC application as a base to learn the correct way to develop MVC applications. I have created Interfaces and Repositories as the reference code suggests and am using Entity Framework for data access. If I want to insert data when a user registers into a table [dbo].[Users], I do not have a control...

Problem with jqGrid in Internet Explorer 8

I have developed an ASP.NET MVC (version 2 RC) application with a ton of jqGrids. It's working like a champ in Firefox, but I've discovered a problem in IE8. The "Main View" grids can be filtered by a search box or one of a few dropdowns above the grid. I use some javascript to reset the url for the grid, then trigger a reload, thusly...

How to properly encode anchor hrefs

What is the proper way to encode URLs in anchor tags in an XHTML/Strict document: <a href="http://www.sit.com/page/&lt;%= HttpUtility.UrlEncode("String that might contain unicode and dangerous characters like +, /, \\, <, >, \", ', =") %>"> Anchor text </a> or <a href="http://www.site.com/page/&lt;%= HttpUtility.HtmlEncode("Strin...

Asp.Net MVC missing style and defaults to logon page

I just setup an out of the box "W2K8 R2 Web" server and installed IIS 7 out of the box. Then I installed the .NET4 framework and ran "aspnet_regiis -i" command. I created a site using .NET 4.0 Integrated app pool. I created an MVC application using the default MVC project template, without modifying I compiled the project and deploy th...

ASP.NET MVC Share logic between actions

Hi! I'm building a site where i need to be able to notify a user on each page. The function is going to look alot like what StackOverflow is using, the yellow(orange?) border at the top. I dont want to reproduce this logic inside all of my actions. DRY. I'm thinking about using a action filter, but since i need to query my data layer i...

Handling post requests in ASP.NET MVC

Recently I started working with MVC, before that I used "classic" ASP.NET. After using Ruby on Rails (RoR), I wonder how to implement POST request handling in MVC similar to how RoR operates. In RoR you use the Post method, so you need only one function for a view. In ASP.NET MVC I need to use 2 separate functions for GET and for POST,...

How to secure Elmah working with ASP.NET and IIS 5.1 URL Routing

This question builds on the following question: How to get Elmah working with ASP.NET and IIS 5.1 URL Routing The solution suggested there worked, as long as elmah.axd is off of the root of the site. What if you want to secure the site as blogged here: Securely Implement ELMAH For Plug And Play Error Logging? Moving elmah.axd to /admi...

Changing an image doesn't work

I have downloaded a MVC project from an Open source and I am trying to make it my own. I want to change images and add different things, new pages etc... When I am changing an image in the content folder (for example the logo appearing at the top of the master page) it is always showing the old one. If I change the name to logo1 for ...

URL Routing parameter name, order

Asking for the best way to address this issue: in my controller I have the following action public ActionResult Member(string id){return View();} another action in the same controller public ActionResult Archive(string year){return View();} in my global.asax routes.MapRoute( "Archive", ...

SOA Architecture with WCF + IOC Structuremap

Hello, I'm a little new to DI containers like StructureMap and I've been using it for a short time with asp.net mvc applications. Now I'm splitting my architecture that will have a WCF service layer and a sort of consumers like ASP.NET MVC app, Silverlight App, And Winfors/WPF App. When using SM with asp.net mvc I've been initializing th...

jQuery enumerate dynamic table

I have a HTML form that mimics invoice input form. This is the way I load invoice items (users select them thru autocomplete list using jQeury): $(document).ready(function() { $("#Products").focus().autocomplete('<%=Url.Action("GetProducts", "Product") %>', { dataType: 'json', parse: function(data) { ...

Multiple custom validation attributes on a class mvc

I am creating a example for better understanding. [CustomValidator("Property1","Property2", ErrorMessage= "Error1")] [CustomValidator("Property3","Property4", ErrorMessage= "Error1")] public class MyViewModel { public string Property1 {get; set;} public string Property2 {get; set;} public string Property3 {get; set;} pub...

ASP.Net MVC Routing URL Generation

Html.ActionLink appends "Index", the action name to the end of the urls, but i would like to not have the index action listed in the default controller url (hope that makes some sense...) Not Wanted: /ControllerName/Index WANTED: /ControllerName Below is my routing setup: routes.MapRoute( null, ...

Access data from Asp.Net MVC URL

So if I have a URL such as mysite.com/user/1234/show which object can I use in the view that is displayed to get at the 1234 int in the URL above? For instance I want to have an action link that uses the user id again for the next controller action call such as mysite.com/user/1234/edit. Thanks ...

Are there any good open-sourced comet web servers for ASP.NET MVC applications?

I'm looking for one that can be used to handle many long poll clients and does not create a thread for each request. ...

How do I serve up an Unauthorized page when a user is not in the Authorized Roles?

I am using the Authorize attribute like this: [Authorize (Roles="Admin, User")] Public ActionResult Index(int id) { // blah } When a user is not in the specified roles, I get an error page (resource not found). So I put the HandleError attribute in also. [Authorize (Roles="Admin, User"), HandleError] Public ActionResult Index(in...

MVC- Not found page http://local.../Articles/1

Can you help me? I used contoller HomeConrtoller.cs for view, edit and delete articles. All work, but When I go to the next page I get error don't found http://local.../Articles/1 public ActionResult Articles(int? page) { var viewData = mybaseRepository.FindAllArticles(); const int pageSize = 10; var paginatedArtic...