asp.net-mvc

Url routing with database lookup?

I want to build a ASP.NET MVC site so that the controller for a specific url is stored in the database instead of the URL. The reason for that is that i'm building a CMS system and the users should be able to change the template (controller) without changing the URL. I also think that the name of the controller is not relevant for the e...

Include JavaScript file in partial views

I am wondering what the best practice is for including javascript files inside partial views. Once rendered this will end up as a js include tag in the middle of my page's html. From my point of view this isn't a nice way of doing this. They belong in the head tag and as such should not prevent the browser from rendering the html in one ...

ASP.NET MVC : Preserve TempData across multiple requests

There are values I need to pass when I perform redirects. I want to use TempData to accomplish this, but have encountered an issue. I use a special controller to generate dynamic JavaScripts. For example, there might be a script tag like this: <script type="text/javascript" src="/Resource/Script/Login.js"></script> ...but there is no...

ASP.NET MVC Session vs Global vs Cache

I have an application that was written in vanilla ASP.NET that I would like to port over to ASP.NET MVC. I, however, am confused about the right place to persist objects. I need to persist for a couple reasons: I would like all to have a single database connection, wrapped in a "repository" or "manager" style object. Each user has a ...

How to create a subdomain on the fly with ASP.Net for a Windows 2008 Server

How can I let web users create a subdomain on the fly for Windows Server 2008 for my website? My application is in MVC 1.0 and ASP.Net 3.5 with C#. ...

ASP.NET MVC Authorization and hyperlinks

Hello, I am using successfully custom authorization in ASP.NET MVC. It simply involves a comparison between User.Identity and the owner of the object in context. It works like a charm when used in simple conditions. It becomes more complicated when I try to call 2 actions in one web request. Lets say I want to display an image which w...

converting validation from the free pdf asp.net mvc nerdinner (c#) to vb.net

how would you convert this code into vb.net since vb doesn't have the yield keyword thanks public IEnumerable<RuleViolation> GetRuleViolations() { if (String.IsNullOrEmpty(Title)) yield return new RuleViolation("Title required", "Title"); if (String.IsNullOrEmpty(Description)) yield return new RuleViolation("Des...

Building a scalable ASP.NET MVC Web Application

I'm currently in the process of building an ASP.NET MVC web application in c#. I want to make sure that this application is built so that it can scale out in the future without the need for major re-factoring. I'm quite keen on using some sort of queue to post any writes to my database base to and have a process which polls that queue ...

Get MembershipProvider's Properties from Web.Config

I derived a class from MembershipProvider in System.Web.Security with the following definition: public class RedditMembershipProvider : MembershipProvider { public RedditMembershipProvider() { } public override int PasswordAttemptWindow { get { return 10; } } /...

ASP.NET (MVC) - render page to a file

Hello, I have to create a bunch of static html files as console / winform job. The current solution uses a string builder. Having used ASP.NET-MVC with strongly typed view pages (System.Web.Mvc.ViewPage) I was wondering if it is possible to leverage these view pages and have them output to a stream or file without building an ASP.NET ...

How to structure, partition, and build large MVC application for deployment in small incremental pieces?

We will be developing a very large vertical market web application, and are leaning toward the MVC approach. It will have 1 Master Page common to all views in the application. The master will provide a navigation/search framework for the entire application that will allow users to search and select entities and then navigate to a functi...

ASP.NET MVC: Should Controllers called by AJAX return JSON or rendered html?

I am having trouble deciding if a controller action, which is called by AJAX, should return a partial view, or the "raw" JSON. Returning a partial view, with rendered HTML makes it easier for the javascript to simply update the current DOM with the returned HTML. However, it does limit what javascript client consuming the webservice can...

Should I Use TDD?

I'm the only developer in my (very small) company and I'm about to start on a medium sized ASP.NET web application for said company. I'm trying to figure out if I should learn Test Driven Development (TDD) and implement it in this application. I need to start developing our new application shortly and I'm worried about testing. I've ...

What control is used on StackOverflow to display posts?

Hi guys, I am building a site in ASP.NET MVC. I intend to replicate the way StackOverflow displays its posts. Are these guys using a repeater control in ASP.NET MVC? I do want complete control on the markup rendered, but I also want pagination. What is the best approach in such a case. ...

How best to share logical types between .NET server code and JavaScript client code?

I have an ASP.NET MVC server app and client code which uses jquery. I'd like to use ajax to transfer objects from client to server and back. On the server, I'd basically just be validating and serializing them. On the client, I have some UI code to create a visual representation and some other code to manage some object properties. M...

MVC Error Question...

Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The type 'System.Web.Mvc.ViewMasterPage' is ambiguous: it could come...

Getting 404 error with ASP.NET MVC starter project

I just created a ASP.NET MVC project and was able to build and browse it using the Visual Studio Development Server. When I tried to change from Visual Studio Development Server to my local IIS (IIS 5.1) under the project properties Web -> Server. I am able to browse to the default page, but when I browse to any other page I get a 40...

How to extend the ValidationSummary HTML Helper in ASP.NET MVC?

I need to wrap the Validation Summary in a div. How do I set the Validation Summary to wrap it with a div when errors are present? <div class="validation-summary"> <%= Html.ValidationSummary("Login was unsuccessful. Please correct the errors and try again.") %> </div> ...

Implementing a Search Box using ASP.NET MVC, SQL Server, Entity Framework

I have no experience building a search solution, but I'd like to have a search box within my solution and I don't know where to even begin. Are there cool SQL Server tricks that I can use to make my search solution performant (I'm using a hosted SQL 2008 server) I'd love pointers to a multi-step tutorial that starts me off with a simpl...

Get the link for a route - Asp.net MVC

I want to get just the link to a route. Using Html.ActionLink and Html.RouteLink returns the link in an anchor tag. Is there any way in which I can get only the link. ...