asp.net-mvc

Adding basic authentication to ASP MVC action

I have an ASP MVC app that uses it's own custom authentication mechanism. However there is only one Action in one controller that I need to secure using Basic Authentication. The idea is when the URL for this particular action is hit, the browser pops up the basic authentication dialog and then I need to have the username and password I...

How to return a specific Json in ASP.NET MVC?

Hello guys, I'm using this plugin http://devthought.com/projects/jquery/textboxlist/ to autocomplete like Facebook Style. I'm just a bit confuse on how to return the Json result that fits the plugin's need. The json result must be like this: [[1, 'John', null, ''],[2,'Mary', null, ''],[3,'Mark', null, '']] The problem is when I retur...

executing SELECT statement with date in WHERE clause fails

I'm building a dynamic query in my ASP.NET MVC project by the following: Dim queryString As String = "SELECT VALUE userInfos FROM MyDBEntities.UserInformations AS userInfos" If strWhere <> "" Then queryString = queryString & " WHERE " & strWhere End If ' Call the constructor with the specified query and the ObjectContext. Dim Sear...

ASP.Net MVC Submit Post Data for Survey

I'm having a hard time figuring out how to collect the data from a FormCollection when submitted for my form which collects the answers for a survey. Specifically my problem is with questions that have multiple choice options(radio buttons) and an other textbox field if the options did not apply. My survey has the following structure: ...

relative dates asp.net mvc

what's the best library for displaying relative dates (eg: 20 minutes ago) for ASP.NET MVC? in C# ...

ASP.NET MVC Ajax LoadingELement on loading a page

Hi, I'm looking on how exactly I can show a "loading element" while the page is first requested. Most examples I find, explain on how to show a "loading element" on an Ajax.BeginForm or Ajax.ActionLink... What I'm trying to do is having a couple of dashboards. When the user requests the page, the dashboards are shown immediately, but t...

MVC 2 Models Directory

Hi, I am busy with an MVC 2 project. I have my entity framework 4 .edmx file in a different project and referenced into my web application. I'm not too sure when I will create model files in my Models directory (created by the MVC application) if my .edmx file is in a separate project. Please can someone help on this confusion. I wo...

How to get the root Url

The code below is a dreadful hack. Uri linkUri = HttpContext.Current.Request.Url; string link = linkUri.ToString().Substring(0, linkUri.ToString().IndexOf("Users/Create")); Instead of editing the string, how do I get the correct route Url in the first place? For example I want to get http://localhost:9999/ instead of http://localhost...

Disable button on submit click in jquery

On submit button i want to disable the button so user does not click more than once. im using jquery for that but its not working, my code is setTimeout($('#btn').attr("disabled", true), 1); return true; button get disabled but my controller does not call. what am i doing wrong? ...

Call a webservice via ssl and use a client pass

I call a webservice via HttpWebRequest. Now the owner of the service send a key and said I would need to use it in the future to access the service via ssl. Is there any way to use this key? The key itself is similar to the key when you prepare your server for ssl. ...

Naming A Form Html.BeginForm()

Any one Know How to give name to a form in Asp.net MVC Html.BeginForm() i want only name not action or controller name because i want to post it through Java Script. Something like this Html.BeginForm(id = "frm") i tried Html.BegainForm(null,null,new{id="frm",name="frm}) Html.BegainForm(new{@id="frm",@name="frm}) But Above code Prod...

ASP.NET mvc, localized routes and the default language for the user

I am using asp.net mvc localized routes. So when a user goes to the english site it is site.com/en/Controller/Action and the swedish is site.com/sv/Controller/Action. But how do I make sure that that when a user enters the site he / she comes to the correct language directly? I do know how to get the language I want, that is not the is...

Reporting Max Request Length Exceeded in an ASP.NET MVC view

I am using a custom HTTPModule to check the size of the request being posted. If it is larger than a given size I would like to stop the request but still render the view with an appropriate error message. I want to make it nice and simple to reuse so in my action perhaps having a ValidationAttribute on the model? Has anyone done this ...

Pass through XML from another website

I am trying to pass through some XML from an external website. What is the best way of doing this, through c# webpage or asp.MVC? ...

Formatting nullable DateTime fields in strong typed View

Hello, I have a Person class with a BornDate property in my model defined as [DisplayName("Born Date")] public DateTime? BornDate { get; set; } I use this field in my view as <td style="white-space:nowrap"> <%= Html.LabelFor(model => model.BornDate)%> <br /> <%= Html.TextBoxFor(model => model.BornDate, new { id = "bornD...

ASP.NET MVC, Autocomplete in jQGrid does not call controller for data.

Hi, Autocomplete does not call corresponding action on Controller. In my case here SharedContoller\FindLocation does not get invoked on typing anything in the textbox of autocomplete. Rest all things are working fine. Declaration of scripts : <script src="../../Scripts/jquery-1.4.2.js" type="text/javascript"></script> <script src=".....

T4MVC: Cannot use a leading .. to exit above the top directory

Hi, I'm trying to use the T4MVC project from the MVCContrib project on codeplex (v2.6.13). I'm using ASP.NET MVC 2 RTM running against .NET 4 in Visual Studio 2010. Using the Default project template that you get when creating a new MVC 2 Web Application I modified the Home ActionLink in the Master Page to: <%= Html.ActionLink("Home", ...

ASP.NET MVC Ajax/Partial views and DRY

Is there a good convention-based way to avoid repetitive code like the following in my controller action methods?: if (Request.IsAjaxRequest()) { return PartialView("EmployeeList", _service.GetEmployees()); } return RedirectToAction("Index"); ...

Updating a Master Page from a View

I have an ASP.NET MVC 2 project that renders conventional strongly typed pages, but on some of these pages I also want to use the page's object to render a specific area (div) in the navigation section of the Master Page. For example, if I have a Client object and associated strongly typed View, I want the View to be able to insert clie...

How to create a fluent style MVC 2 Html.Helper?

Hi! Could someone point me in the right direction on how would I go about creating htmlhelpers that you could call in the view something like the code below. <% using (Html.BeginSvg()) {%> <% using (Html.BeginGroup("Group1")) {%> <%= Html.SvgLine("Line1").Class("blueLine").Style("stroke-width:2px").X1(25).Y1(25).X2(25)....