asp.net-mvc

Retrieve the current view name in ASP.NET MVC?

I have a partial view (control) that's used across several view pages, and I need to pass the name of the current view back to the controller - so if there's e.g. validation errors, I can re-draw the original view. A workaround way to do it would be (in the controller methods) var viewName = "Details"; // or whatever ViewData["viewName...

Can you run an ASP.NET MVC application from its project folder?

In IIS 5.1, I have setup a website to point to my ASP.NET MVC project directory, and I get a "Service Unavailable" error when I try to access it after building the project. It seems I have to publish the site to a separate directory and point IIS to the published version to get it to work. I have already tried "aspnet_regiis" but that d...

How do I prevent JSON serialization in ASP.NET MVC?

While developing an ASP.NET MVC app, I'm finding a few places where my JsonResult actions throw an exception "A circular reference was detected while serializing an object". For now, I'm removing the references in question, but ideally I'd like to simply mark the property such that the JSON serializer ignores it. Can anyone suggest how...

How do I get an ASP.Net MVC application running on my host?

Is there something special you usually have to do? I have a DailyRazor .Net Starter account, but it won't run my MVC app. Any ideas? I have contacted support but they said it should work, but it's not... Thought maybe someone here could help me faster. ...

Unit tests on MVC validation

How can I test that my controller action is putting the correct errors in the ModelState when validating an entity, when I'm using DataAnnotation validation in MVC 2 Preview 1? Some code to illustrate. First, the action: [HttpPost] public ActionResult Index(BlogPost b) { if(ModelState.IsValid) { ...

Complex model binding

I have a Client dto that contains a bunch of fields and also contains a List. Now, I can bind to it quite easy, and it will display the Client with all of his addresses. The thing is that the user can delete and add addresses dynamically. I thought about adding forms surrounding each address but then I end up with inner forms and I k...

MVC Ajax form not submitting on IE

I have an ASP.NET MVC ajax form fully working on FireFox. Here's how the code looks like: <% using (Ajax.BeginForm("SendMessage", "Contact", new AjaxOptions { OnComplete = "ProcessResult" })) { %> <div id="inputArea"> <label for="Name" class="contactLabel">Your Name:</label> <%= Html.TextBox("SenderName", Model.Contact.SenderN...

wildcards in asp.net mvc routes

Hi, i'm using asp.net mvc with vs2008 and IIS7. What i want to accomplish is that all requests that START WITH 'summer' are routed to the same controller. 'till now i've built tons of routes, but they were all for one path (with parameters offcourse) but this one must route: www.mysite.com/summercity www.mysite.com/summermadness www.mys...

Are there any view engines for ASP MVC that are 'designable'?

Here's my problem: I am disturbed by the "impedance mismatch" between what graphic/web designers actually produce, and what is needed by the standard ASP MVC view engine. Basically there is no way to visually design a view i.e. the output of an action. No WYSIWIG designer. The only way to go from a static HTML design to an MVC app is b...

Getting started with Elmah?

Hi all, I've read http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx and would like to use it in my mvc application; I'm running the MVC 2 preview. My problem is, that when I follow instructions in article (providing dll and modifying web.config), I encounter an error when accessing http://localhos...

Hosting a WCF service in an ASP.NET MVC app?

Howdy, I have a pretty big webapp that's being built in MVC. I'm also abstracting common code into a framework which sits in a separate project. Hopefully this framework will be used in other projects in the near future. There are a few Silverlight apps that are a part of this framework, and one of their jobs is to upload files a chu...

jquery adding an onclick event to a href link

i am converting over from websforms to asp.net mvc and i have a question. i have a loop that generates links dynamicallly where picNumberLink is a variable in a loop and image is a variable image link. i want to avoid putting javascript actions inline so in my webforms project is did the following: hyperLink.Attributes.Add("onclick"...

jQuery: why does $.post does a GET instead of a POST

I'm trying to do an ajax call and populate the "Data" div with the results of the ajax call, but i get an error saying: "Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. Requested URL: /Home/GetStuff" When I look with Firebug the request was a GET to /Home/GetStuff and the answer was 404 Not found. Wh...

ASP.NET MVC Newbie: why isn't my model available when creating a strongly-typed view?

I'm starting with ASP.NET MVC, and working with NerdDinner as reference. I did the following: Created a new project Added a couple of tables Created LINQ to SQL for them Created a new controller My Models directory now contains MyModel.dbml, under which I have MyModel.designer.cs, that contains classes for models relating to both of...

How to use Server Controls with PostBack with ASP.NET MVC?

Once I click the button, it throws a "Validation of viewstate MAC failed" exception. I know MVC does not support PostBack but is there any way to work around this? Or we need to use HtmlHelper in MVC? Below is my code in View: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <form id="form1" runat="server...

ASP.NET MVC: Can't get string parameter in my controller

Hello, I have the following code in my controller called UserController: public ActionResult Details(string name) { MyModelDataContext db = new MyModelDataContext(); Product user = db.Products.Single(t => t.Name == name); return View(user); } I expect that when I browse directly to http://localhost:port/User/Details/SomeN...

JQGrid not reaching MVC controller

Using FireBug I know the url is http://localhost:21962/Home/DynamicGridData/?nd=1250169669898&amp;%5Fsearch=false&amp;rows=10&amp;page=1&amp;sidx=Id&amp;sord=desc It is not making it to my HomeController. Here are the actions I have tried to make receive the JQGrid call public ActionResult DynamicGridData(long nd, bool search, int row...

A session factory has already been configured with the key of nhibernate.current_session

NOTE: I posted this on sharp architecture google groups also. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: SharpArch.Core.PreconditionException: A session factory ha...

DisconnectedContext Error while running Unit Test project in VS 2008

I have a unit test project inside my solution. I keep adding new unit tests and modifying old ones. Some days ago, a message box keeps appearing when running my unit test project. The message box say: DisconnectedContext was detected Message: Context 0x2aae50' is disconnected. Releasing the interfaces from the current context (cont...

Is right use strongly-typed partial views?

Hello, everybody. I'm developing a little application in ASP.NET MVC. This app has a lot of "HTML pieces" that are used many times with a little variance. For this pieces, I'm using strongly-typed partial views. My question is: This is the right way to reuse code in View layer? Is there some inconviniece to use partials views? Thank...