asp.net-mvc

How can Asp.net MVC treats an aspx page call and redirects it?

Hi! On the project I'm working, it previous version was build on ASP.NET classic (aspx) and now this very same project is build on ASP.NET MVC. But, some users may still call the older pages (for example, an user add the old page to his favorites) and when this happens MVC throws an error. How can I identify if an aspx page is being c...

MVC Calling another controllers action

I have started an MVC project and it has created the AccountController Class for me. So to login to my current site I would have to go to, localhost:2500\Account.mvc\LogOn I wanted to make the login on my HomeController in the Index view. So basically if you go to my root of the site if not authenticated you would have to login to go an...

HTTP POST from a ASP.NET MVC Ajax form does not include submit buttons.

I am unable to determine which form submit button is clicked during an Ajax Form POST in ASP.NET MVC. I have a form that basically looks like: <% using (Ajax.BeginForm("Edit", new { code = Model.Code }, new AjaxOptions() { UpdateTargetId = "re...

Asp.net MVC authentication ticked without create auth cookie

I'm authenticating a user in my application with the method "FormsAuthentication.SetAuthCookie" method, but when I close the browser and reopen it, it is still authenticated, but the session is over already, then my app crashes because it has necessary data on the session to generate the menus. What I want to do is the following: Create...

Entity Framework Error on creation

I get the following error: "ERROR: Unable to update Web.Config because of the following exception: 'The value contains embedded nulls (\u0000). Parameter name: provider connection string'." All I'm doing is adding a new model to my ASP.Net MVC app..... Just to be clear, this is when the wizard creates the model from the DB... ...

Is my form not submitting by design or is there something else going on here?

Hello SO: I am working in ASP.NET MVC and made a simple form that is AJAX enabled (using MicrosoftAjax and MicrosoftMvcAjax). All it does is pass the form value to a partial view, then updates the target element with the new value. Here is the view with the form: <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat=...

Does ASP.NET MVC have the App_Code concept?

Does ASP.NET MVC have the App_Code concept? ...

ASP.NET MVC: action methods with one param not named ID and non-integer

Consider an ASP.NET MVC 1.0 project using the Areas convention as described on this Nov. 2008 Phil Haack blog post. This solution works great once it's set up! My trouble is starting thanks to my limited knowledge of ASP.NET MVC's routing rules. My intention is to create an action method and URL structure like this: http://mysite/...

HTTP 500 error in Apache/mod_mono but not in xsp

My ASP.NET MVC application has been successfully ported to Mono. It works very well in xsp on port 8080, including the OpenID authorization process which is relying on RPX. In the process, the website makes some calls to RPX API (https://rpxnow.com/api/v2/...) in the background. At first, it triggered a HTTP 500 error in xsp. The problem...

ASP.NET MVC: Populating Derived Strongly Typed View with Base Strongly Typed View

In my application I have different pages: Contact Us, About Us, Home They all have the same base elements that needs to populate the view: Page Title Meta Description User Information However on each page, they have some elements that are different: Contact Us Contact Information Model Contact Form Model About Us Extended Use...

Stop Html.ValidationSummary() from changing the order of validation messages

Is there any reason why ValidationMessages would display in a different order than the order you added the model errors? I can't really help much because I have no idea how Html.ValidationSummary works to output what it does. If there's anything I could add that would help diagnose the problem, please comment and I'll add it if I can. ...

How to return nested, one to many relationship in a ASP.NET MVC json response?

How would you format a Json response to include nested, one to many related data? My simple JQuery Autocomplete example. The Linq2Sql is within. The first part of this question answered here. This uses a repository with Linq 2 SQL to send the response: public IQueryable GetProductIDs(string myPrefix, int limit) { return from z i...

Fetching data within an ASP.NET MVC ViewModel class?

For those that create ViewModels (for use by typed views) in ASP.NET MVC, do you prefer to fetch the data from a service/repository from within the ViewModel, or the controller classes? For example, we started by having ViewModels essentially being DTOs and allowing our Controllers to fetch the data (grossly oversimplified example assum...

Disable Session state per-request in ASP.Net MVC

Hi, I am creating an ActionResult in ASP.Net MVC to serve images. With Session state enabled, IIS will only handle one request at a time from the same user. (This is true not just in MVC.) Therefore, on a page with multiple images calling back to this Action, only one image request can be handled at a time. It's synchronous. I'd like ...

Getting value from a Masterpage in the controller Asp.Net MVC

How do I get value of a textbox thats placed in the masterpage? Please help me.. Thanks. ...

How do i use Application_Error in ASP.NET MVC?

Hey I want to use Application_Error with my MVC project, but i can't get it to work. I add the following to my Global.asax file: protected void Application_Error(object sender, EventArgs e) { Exception objErr = Server.GetLastError().GetBaseException(); Session["Test"] = "Message:" + objErr.Message.ToString(); ...

Redirect to getter if the set value of the data property does not meet the condition

Hi Guys, I want to default value(getter value) to be set for the data property , if the value set by the user does not meet the condition(without private variables). Here is the code public class TreeViewModel { public a() { this.Height = 200; } public int Height { get; set ; } } If the user sets the value of height less...

If Statement Hell, How to check if a date passed matches a date within 3 days but only if the date doesnt match the other conditions.

As the garbled question says I'm basically looking for a tidier way to do the following snip. (its used in a calendar for availability matching) //TODO: Optimize elseif Statement if (date.Year == now.Year && date.Month == now.Month && day == now.Day) { daysXhtml.Append("<td class=\"today\">" + day.ToS...

Embeded code blocks in masterpage and page

Well I'm some what baffled! 'Simple problem' I have parts of my master page that I want to render differently depending on whether or not a ContentPlaceHolder is empty. So: I have a master page that as some code like: <% if (ContentPlaceHolder1.HasControls()) {%> <div id="LittleDiv"> <% } else { %> <div id="BigDiv"> <% } %> ...

Best way to maintain session state in MVC

I have a search bar with 4 cascading dropdowns on it, the user makes a selection then clicks search. When the user returns to the search page I want the previous selected values to still be displayed. Any comments on the best way to save these selected values? ...