asp.net-mvc

Global routing parameter in ASP.NET MVC

When a user clicks on a link, I want to log some information. I can't do an AJAX request because if they clicked on a link, the page will unload (since they're going to a new page), and I don't want to force them to stay on the page until a synchronous event finishes. So one idea I had was to add a parameter to the url. I.e. the urls w...

Using WCF with wsHttpBinding with Web Forms vs MVC

I have used WCF in the past with my Webforms so my solution was MyWebformApp = WCF(Model+business) + Web Forms So when I want to work with the MVC for presentation arch. How do u use WCF with ASP.net MVC ? Are your data contracts a part of the model ? How do you register the datacontracts as properties? ...

Is there a better way to specify default section content in asp.net mvc razor layouts?

With the asp.net mvc web form engine, you could define a content placeholder and specify the default content. How is this done with Razor engine? This is the only way I found - but it seems like there would be a better way. _Layout.cshtml: @if (IsSectionDefined("Footer")) { @RenderSection("Footer") } else { <text>Default fo...

ASP.NET MVC Lightweight Login/Registration system

I'm on my first MVC project and am at a point where I need to implement my membership system. I'm not sure whether using the out-of-the-box membership system is a good choice for me given that all I need is a simple login/registration system like the one at Digg. My UserId field is a foreign key to many other tables, which is why I th...

ASP.NET MVC MultiSelectList with selected values not selecting properly

I know others have asked this question, but I'm totally confused by this: This displays the dropdown with no values selected: <%= Html.DropDownList("items", new MultiSelectList(Model.AvailableItems, "id", "name", Model.items), new { multiple = "multiple" })%> This displays the dropdown with the values that I'm passing in (Model.i...

jQuery not working in IE when selecting an item in dropdown

I have a dropdown that shows countries. When the user selects United States or Canada, then another drop drop will appear. Everything works with Firefox, but not with Internet Explorer. $(document).ready(function() { $('.CountriesDropDown').change(changeAddressOptions); // alert('loaded'); // call change event in case value w...

Should I use the DotNetOpenAuth OpenIdRelyingParty RedirectingResponse.AsActionResult or RedirectToProvider in MVC?

I've implemented an OpenID controller using Dnoa. I was using the approach found in the RP MVC template for dnoa, which returns IAuthenticationRequest.RedirectingResponse.AsActionResult() from the controller action. However, I've now found the controller very difficult to test using Moq because of this method. I changed the controller ...

Problem in GetRuleViolations method in NerdDinner tutotial

Hi All. I'm on about page 70 of the NerdDinner tutorial (MVC 1.0 version). It won't build at this point because it is saying the properties referred to in the GetRuleViolations (ie, Title, Description, etc) can't be resolved. I've compared my own project with the downloadable source code and can't figure out what is missing. The error VS...

How to limit access to an [HttpGet] ActionResult in ASP.NET MVC?

Imagine I have an ActionResult like this: [HttpGet] public ActionResult Cities(string q) { //Return a list of cities that matches parameter } How do I stop all other sites apart from mine using this as if it's their own little REST-based service for getting a list of matching cities? Is checking the referrer the only way to go...

ASP.NET Universal Login from Multiple Sites

Hey everyone! I have a question that doesn't need any specific answer, just a general direction of what to do. I work for a company that has many sites. Each site requires a login at some point. We have a single Accounts database that all of the sites hit. One of the requirements for the login system is that if we login on one site,...

How do I set a custom view engine from within the controller?

I'd like to set a custom view engine from within a controller that is specific to that controller. Or is there some configuration-based way to tell the framework to use the custom view engine only for that specific controller? ...

NerdDinner main logo link

I have uploaded the nerddinner sample to "www.example.com/test/nerd". When a mouse is on menu tab such as "Find a host" then the link is shown at the bottom of Internet explorer as "www.example.com/test/nerd/Dinner" with the contoller name "Dinner". When the mouse is on the main logo which is on top and left, the link shown as "www.examp...

How to package asp.net web application w/o visual studio?

I got test server which I would like to use for CI too. Plan is to setup Hudson that listens to git repository, on new commit fetches changes, builds solution, runs tests (picks up output), setups test environment web application if everything looks green and shows Chuck Norris. I'm struggling with first part (git ports are closed atm ...

Global.asax Exception Handling and HTTP Error Codes

I have a fairly standard MVC2 app running on 4.0 and under IIS6. I took the wildcard filter approach to route all requests to the asp.net ISAPI filter. So far so good. I have now added some code to Application_Error in the global.asax to trap exceptions and email me the stack, etc. This also works fine. But, I am receiving all kinds of...

MbUnit's row attribute in Visual Studio 2010?

While reading an Asp.Net MVC code sample that used MbUnit as its testing framework, I saw that it was possible to run a single test against multiple input possibilities by using a Row attribute, like so: [Test] [Row("test@test_test.com")] [Row("sdfdf dsfsdf")] [Row("[email protected]")] public void Invalid_Emails_Should_Return_False(string inv...

When is it appropriate to use CacheItemRemovedCallback?

I have a large data set that is updated once a day. I am caching the results of an expensive query on that data but I want to update that cache each day. I am considering using CacheItemRemovedCallback to reload my cache on a daily interval, but I had the following concerns: Isn't it possible that the CacheItemRemovedCallback could be ...

how to unit test session state

I'm trying to figure out how to unit test my object that persists itself to session state. The controller does something like... [HttpPost] public ActionResult Update(Account a) { SessionManager sm = SessionManager.FromSessionState(HttpContext.Current.Session); if ( a.equals(sm.Account) ) sm.Acco...

ASP.NET MVC - Downloadable reference documentation?

I use VS2008 (with Document Explorer-based documentation, y'know... before it started sucking with VS2010) and ASP.NET WebForm's documentation is all there. I don't need internet access to get documentation on a given built-in Control or general 'how to' documentation. But I can't see any downloadable Document Explorer content set for A...

MVC Deleting objects with EntityFramework on Delete failure EF trashes relationships

ASP.NET 4.0 MVC 2.0 EF 4.0 For my code below, the view accesses a navigation property on the img and is throwing a null reference exception when the database cannot perform the operation. This happens with both .Include on the context and LazyLoadingEnabled==true. My navigation property becomes null right after SaveChanges. But SaveCh...

Where to store custom classes in ASP.NET MVC?

A bit of a silly question, but if I want to create a custom class that's not a controller or model, where should I put it. In WebForms, I stored all my classes in the App_Code folder, but it seems like classes aren't stored there in MVC. Does it even matter? ...