asp.net-mvc

How to catch 500 internal server error in c#

Im using Google Analytics Dashboard Control which are available at http://gadashboardcontrols.codeplex.com/ Issue is its working fine when im connected to internet but if im using it on a machine that doesnt have internet access then it shows Server Error in '/' Application. The remote name could not be resolved: 'www.google.com' ...

Validation with Ajax and MVC

I am looking at the best way to take advantage of the MVC validation while using Ajax and not having access to a class. On my masterpage it will contain a simple form (name, email, tel, comments) which I display in a overlay. As this is in the masterpage is available on any page, The masterpage never inherits a class like you would do w...

How can I reuse Model Metadata for custom View Models?

Hi, I'm working on an ASP.NET MVC 2 project with some business entities that have metadata dataannotations attributes applied to them (Validation attributes, Display attributes, etc.). Something like: //User entity public class User { [DisplayName("Vorname")] [Required(ErrorMessage = "Vorname fehlt")] ...

How to include quote characters as a route parameter? Getting "Illegal characters in path" message

I have a search box that exists on all pages. The user can enter text, and click search and they end up on the Search page with the results displayed for them. When search is clicked, the form containing the textbox is sent off to the following route: http://localhost:2010/search/my%20search%20term this works. But if I put quotes aro...

SqlCacheDependency leads to lots of queries to my db

I have implemented my own SqlCacheDependency public SqlCacheDependency CacheControllerDependency(CacheControllerKeys cacheKey) { SqlConnection conn = new SqlConnection("connection"); try { SqlCommand command = new SqlCommand( @"SELECT [CacheName] ,[CacheReloadDate] ,[CacheRelo...

What are typical ASP.NET MVC - Controller Action Name conventions ?

I'm struggling to choose appropriate names for my actions. I want to distinguish between actions that return a view to: Create Edit Edit-Create Here is what I have so far: Create --> Show the Empty Form for Create Add --> Receives data from Create and Save New Entity Edit --> Shows Existing Entity in a form for editi...

ASP.NET MVC 2.0 - Difference between RenderPartial and RenderAction

I am trying to understand the difference between a RenderPartial and RenderAction. I guess that RenderPartial is like a UserControl and RenderAction is like a server-side include. Can someone put this in perspective please and if possible give me a couple scenarios of where each would be used? ...

How to read json file format and how to write the json in c# asp.net

In my ASP.NET MVC project I am conecting to a remote cloud server which is returning the data in json like: [{ "name":"new-service-dev", "Isenabled":"true", "ttl":86400, "cdn_uri":"http://c0099.cdn2.files.rackspacecloud.com", "referrer_acl":"", "useragent_acl":"", "log_":"false" }] Now I want to get all th...

Populate password on the login page using MVC

I am implementing single sign on and i have the login name and password from the parent site and would like to insert this values in the login and password field of the child site. How can i do this in C#, MVC. as of now i am able to populate the login name using viewdata but i m unable to populate the password. ...

asp.net mvc regular expression enter

^[a-zA-Z0-9-_. ]*$ for textarea I want to make available the enter as well in the following regular expression. How would I do that? ...

Best practice for managing/generating policy numbers

I am currently working on a website which allows a prospect to generate a quote and purchase a policy. After they submit their payment the application should generate a policy number. I was given a block of policy numbers to use incrementally. For this example, let's say 0100800 - 0100999. If I have two or more people who decide t...

How to validate a path in ASP.NET MVC 2?

I have a custom attribute that checks conditions and redirects the user to parts of the application as is necessary per business requirements. The code below is typical: public override void OnActionExecuting(ActionExecutingContext filterContext) { // ... if (condition) { RouteValueDictionary redirectTargetDictionary = new R...

How to Moq a Method that Have parameters and have to do something with a list

I have set a test using Moq 3.0. I need to test a method that will change some value in that database. I am using ASP.NET MVC so I want to test my controller. I setup this // Generate an implementer of IProductsRepository at runtime using Moq var mockTareasRepos = new Mock<IRepository>(); mockTareasRepos.Setup(x => x.ExecutedTask).R...

How to prevent a ModelBinder error in a mandatory fields of a list?

I've got this object created from EntityFramework from my database. [EdmEntityTypeAttribute(NamespaceName="ContactCoreModel", Name="TargetLang")] [Serializable()] [DataContractAttribute(IsReference=true)] public partial class TargetLang : EntityObject { #region Factory Method /// <summary> /// Create a new TargetLang object...

Creating ASP.NET MVC style views in a console application?

I have a console application that requires me to send out e-mails. Right now I use a string builder to create the e-mails, but I'd like to get more fancy. Then it dawned on me: it would be nice to send my object to an ASP.NET MVC style view, where I'd have the HTML markup, and then return it to mail out. Right now, I have it going as; ...

ASP.NET MVC - Replace label with validation error message?

I'd like to highlight field names instead of showing a separate error message when there is a validation error. Is there any convenient way of doing this other than checking the ModelState Errors collection and wrapping each .LabelFor() in an if? Also, I'd like to format labels as either bold, or add an asterisk if the model metadata h...

Complications when upgrading from ASP MVC 3 Preview 1 to beta

I have just upgraded my ASP MVC 3 application from the preview to the beta version. In preview everything worked fine, but as soon as I upgraded weird things started to happen. I get this error message: Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you mi...

ASP.NET MVC: using EF entities as viewmodels?

Possible Duplicate: ASP.NET MVC - Linq to Entities model as the ViewModel - is this good practice? Is is OK to use EF entities classes as view models in ASP.NET MVC? What if viewmodel is 90% the same of EF entity class? Let's say I have a Survey class in Entity Framework model. It 90% matches data required for view to edit i...

MVCContrib Pager not emitting my query string

Hello, How do I get my original query string appended to the end of the pager output? All I am getting now is this: http://localhost:4988/Assets/Browse/1?page=2&amp;Visible=false I need all the various name/value pairs from my query string appended onto the next/previous links. Also, what is “visible” used for in the above link? I d...

help with TFS and referenced DLLs

We are using TFS and VS 2010. I have been working on a project that is using TFS as source control. I have quite a few dlls that I have downloaded (such as log4net) and referenced in my project. When a new programmer connected to TFS and got my project out of source control, it failed to build as it said it was missing all these refer...