asp.net-mvc-2

MVC Action called twice

不羁的心 提交于 2019-12-10 10:10:52
问题 I have a MVC Action Method which is being hit twice if the request takes time to complete. On checking chrome console network log and fiddler, the request is being sent only once from the JS. In the diagram below, I'm facing this issue with Approach 1 . However, it works fine if I do it with Approach 2 . What’s happening with Approach 1 (failure): JS hits MVC Action with window.location.href . Ideal scenario as per code MVC Action (Time taking process) Calls Service Method 1 Calls Service

Routing in ASP.NET MVC 2.0

自闭症网瘾萝莉.ら 提交于 2019-12-10 10:06:10
问题 I'm looking to make a really simple route in my ASP.NET MVC 2.0 website. I've been googling for help but all the examples I can find are for really complex routing. Basically I want all the pages in my Home Controller to resolve after the domain as opposed to /Home/ For example I want http://www.MyWebsite.com/Home/LandingPage/ To become http://www.MyWebsite.com/LandingPage/ But only for the Home controller, I want the rest of my controllers to function as normal. I thought about creating a

How do you create an HtmlHelper outside of a view in ASP.NET MVC 2.0?

拜拜、爱过 提交于 2019-12-10 09:22:36
问题 We are in the process of upgrading an ASP.NET MVC 1.0 application to the 2.0 release and some of the code requires the use of LinkExtensions which require an HtmlHelper to render. While we know that some of the code doesn't follow the MVC model correctly and are in the process of recoding as needed, we need something to work so get the application to build. Here is the current syntax that we have that works under ASP.NET MVC 1.0: public static HtmlHelper GetHtmlHelper(ControllerContext

Caching Data .Net 4.0 (Asp.NET)

给你一囗甜甜゛ 提交于 2019-12-10 09:05:50
问题 Can anybody explane me what is " CacheSpecificEviction " in detail and how to avoid it? I am geting this in CacheEntryRemovedArguments.RemovedReason . 回答1: CacheSpecificEviction as reason for removing cache entry means "the item was removed, because the cache provider's eviction policy determined it should be removed" - I know, it is pretty unspecific, but it hardly can be more specific, because of many possible cache-engine implementations and their different eviction policies (often

Creating a dropdownlist from your controller or view model

落花浮王杯 提交于 2019-12-10 07:19:40
问题 How would I create a SelectList in my controller and pass it to my view? I need to give the "-- Select --" option a value of 0. I'm responding to the replies that I got from Jeremey of Fluent Validation. This is what I currently have. My view model: [Validator(typeof(CreateCategoryViewModelValidator))] public class CreateCategoryViewModel { public CreateCategoryViewModel() { IsActive = true; } public string Name { get; set; } public string Description { get; set; } public string MetaKeywords

Why use Url.Content for referencing resources?

笑着哭i 提交于 2019-12-10 05:10:22
问题 In almost every ASP.NET MVC example I've come across, I always see Url.Content being used to reference CSS, JavaScript, and Images. Not once has anyone explained WHY to use it. Anyone care to explain? What's so bad about doing: <img src="/Content/Img/MyImage.png" alt="My Image" /> <script src="/Scripts/jquery.js" type="text/javascript"></script> <link href="/Content/Css/Default.css" rel="stylesheet" type="text/css" media="all" /> 回答1: What you have works the same as Url.Content(). Url.Content

separate numbers by comma with asp.net mvc

浪尽此生 提交于 2019-12-10 03:19:18
问题 I am working on an MVC2 appication. I use data annotations to validate data (both client side and server side). I have several fields in my model that only allows decimal values. As soon as a user types a decimal values I want it to be converted to comma seperated more readable format. For instance 1200 should be formatted to 1,200 while 500 should stay as it is. Here is my model: public virtual GrossFee? Fee { get; set; } And here is how it is on the view: %: Html.TextBoxFor(model => model

ASP.NET MVC: generating action link with custom html in it

两盒软妹~` 提交于 2019-12-10 03:15:09
问题 How can I generate action link with custom html inside. Like following: <a href="http://blah-blah/....."> <span class="icon"/> New customer </a> 回答1: You can use the UrlHelper class : <a href="<% =Url.Action("Create","Customers") %>"> <span class="icon"/> New customer </a> The MSDN link is here : http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx 来源: https://stackoverflow.com/questions/3879547/asp-net-mvc-generating-action-link-with-custom-html-in-it

Paypal Recurring Payment Transaction Error: 11502 : Token is invalid

纵然是瞬间 提交于 2019-12-10 03:02:43
问题 I am new to paypal and I need to implement a subscription ( recurring payment) for my client.I am using paypal sandbox for its implementation. I followed the way that the paypal insists for creating a recurring payment profile. On getting "success" acknowlegment from SetExpressCheckout, GetExpressCheckOut and DoExpressCheckOut . I have tried to create the Recurring Payment Profile with the token from the DoExpressCheckOutpayment response, but the response from the CreateRecurrinpayment

“Dynamic operations can only be performed in homogenous AppDomain” error

纵饮孤独 提交于 2019-12-10 02:23:45
问题 I'm getting this error when running an MVC3 site on my locahost. It is a fresh MVC3 site just newly created, the HomeController Index method is where it's being thrown from, on the ViewBag.Message assignment. public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; return View(); } Stack trace: at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0,