asp.net-mvc

how to localize an asp.net mvc webproject? languages support

Hello, I would like to support many languages in an MVC project. I did it already using WebForms. I used LocalizedPage class inherited from Page. In MVC I am inheriting LocalizedPage from a System.Web.MVC.ViewPage, public class LocalizedPage : System.Web.Mvc.ViewPage and then my model uses it like this: public class OverviewModel ...

ASP.NET MVC: How to automatically disable [RequireHttps] on localhost?

I want my login page to be SSL only: [RequireHttps] public ActionResult Login() { if (Helper.LoggedIn) { Response.Redirect("/account/stats"); } return View(); } But obviously it doesn't work on localhost when I develop and debug my application. I don't wanna use IIS 7 with S...

Is it possible to use Razor View Engine outside asp.net

If I look at the Razor View Engine, then I see a very nice and concise syntax that is not particularly tied to generating html. So I wonder, how easy would it be to use the engine outside asp.net in a "normal" .net environment for example to generate text, code,... Any pointer, example, comment or explanation is welcome. ...

Strongly typed model passed in to the view is handled as object. Why???

Dear All, I am taking over quite a big ASP.NET MVC project, and I am just trying to make it work on my computer. It is asp.net MVC 1 project and I will continue developing in with Visual Studio 2010. I have set up the database and everything however I have a strange problem and no clue why it happens: the project uses strongly typed v...

MVC - No errors on Visual Studio 2010 compilation

Hi there, I having a situation with my VS2010, while using MVC, and I would like to know if anyone have the same situation. My VS2010 don't check if class defined in ASPX pages header exists, or class property in ASPX during compilation. Best regards ...

Web Service/Web Config Issues

So I get thrown an exception right when I try to create a new instance of my Web Service that says: "Could not find default endpoint element that references contract 'KBBVehicleService.IVehicleInformationService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application,...

with mvc.net is it possible to share a view between multiple actions

This is a noob question, but I will ask it anyway... I'm wanting to create a page that will do basic CRUD operations on a list of items: -display the list -edit an item -create an item -delete an item It is looking like I will need an action for each of this operations. This is good and understandable. My question is regarding the vi...

What's the most efficient way of getting the culture info from server to client

I'm letting users choose their preferred language setting for number, currency and date formats. I've got this implemented in a filter to set the Current(UI)Culture. Now I want to use that culture information on the client to setup jQuery's datepicker. What would be the most efficient way of getting the configured culture setting to the...

Page.EnableSessionState equivalent in ASP.NET MVC

With ASP.NET WebForms it is possible to set the session state mode in the page directive: <%@ Page EnableSessionState="true|false|ReadOnly" %> Is the same configuration also possible in ASP.NET MVC (e.g. per controller or per action) and if so, how? (In other words: can I disable or set to read-only session state per controllers/acti...

MVC View html ouput in json

Probably this has been asked so many times before but i can't find answer any where. I have a Action public ActionResult SearchResult() { return View(); } Now i need some data as well which is related to View, so i am trying to do following public JsonResult SearchResult() { var result = new JsonResult(); result.Data = new...

ASP.NET MVC Html.TextBoxFor rendered different value than <%: Model.value %>

This is very strange and I don't know why. I have a ViewModel that return some value for my object, when rendering it, they have different values, yet, they points to the same property: <%: Model.myProperty %> That returns "25", which is what I've set the property to be. But when rendered it as an textbox, it returned "0" as the value...

Exception Details: System.ArgumentException: Illegal characters in path. ASP.NET MVC

Hi, I have a problem using ASP MVC with C#. When I create an aspx page with a strongly typed inherit I received the following error: Server Error in '/' Application. Illegal characters in path. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more informatio...

ASP.NET MVC Routing: How do I redirect all actions to Base Url?

Hello! Is there anyway to make all actions in a given controller to redirect to the server root? For example, if I have a URL with controller Home and action terms I want that to the URL to become /terms If I have another URL with controller Home and action privacy, then the URL should become /privacy. I am able to do this by hard-co...

Why is this View Model being populated when I pass "" into RenderAction?

I'm trying to implement a Widget control that exists on every page in the system, which will allow the user to have basic Search & Directory functionality available on each page. This is a tab control defined below, where in the <ul> the currently selected tab is determined by the the value in Model.CurrentTab and the corresponding conte...

What's the design pattern name for using domain models & view models (aka AutoMapper) with MVC

Is there a name for the software design pattern that involves MVC with domain models and view models? It's the pattern used when a tool like AutoMapper is employed. I was attempting to explain the advantages of such a design to some fellow programmers and was calling it MVVM but I'm now of the opinion that's not right and the MVVM patte...

increment label

I have a button that adds a new row to the view with the following code. Is there a way to increment the label? What I would like is to say "Name 1:" "Name 2:" for every row. string s = "<table>\r\n"; s += " <tr>\r\n"; s += " <td>\r\n"; s += " <label>Name: </label>"; s += " <input></input>"; s += " </td>\r\n"; s +...

type submit vs type button

I have a button which right now is set as a type "submit". This calls the controller, execute some code and returns back to the view. When I use jquery to hide the button, I see that when I click on the button, what I have hides the button but as soon as the view is returned, the button is not hidden no more. Whereas with type "button", ...

Working with MVC 2.0 and the Model in a separate assembly

Hi, I'm new to MVC and even though there is a lot (and I do mean a lot) of information out there that is very useful - it's proofing very difficult to get a clear understanding on how to achieve my exact requirements with MVC 2.0. I would like to set up a solution as follows: Provide a web UI using an MVC 2.0 project. Use Linq to SQL ...

Entity Framework + Unity Framework

Hello, I beginning a new project and I need to create a Project for implementing Entity Framework 4.0 and Unity Framework 2.0 along with Enterprise Library 5.0. I am very new to Entity Framework and Unity Framework and getting confused in how I can get normal Object BO's and DAL with Database. Can someone point me to some simple exampl...

Robots.txt, disallow multilanguage URL

I have a public page that is not supposed be possible for users to sign into. So I have a url that there is no link to and you have to enter manually and then sign in. The url is multilanguage however, so it can be "/SV/Account/Logon" or "/EN/Account/Logon" etc etc. Can I disable this url to be indexed for all languages? ...