小编Jit*_*oli的帖子

使用Dictionary <string,string>的下拉列表不适用于所选值

我试图以这种方式绑定MVC3中的下拉列表.

模型

public static Dictionary<string, string> SexPreference()
{
      var dict = new Dictionary<string, string>();
      dict.Add("Straight", "S");
      dict.Add("Gay", "G");
      dict.Add("Bisexual", "BISEX");
      dict.Add("Bicurious", "BICUR");
      return dict;
}
Run Code Online (Sandbox Code Playgroud)

调节器

ViewBag.SexPreference = MemberHandler.SexPreference();
Run Code Online (Sandbox Code Playgroud)

视图

@{
var itemsSexPreference = new SelectList(ViewBag.SexPreference, "Value", "Key", Model.sexpreference);
}

@Html.DropDownListFor(m => m.sexpreference, @itemsSexPreference)
Run Code Online (Sandbox Code Playgroud)

下拉列表没有选择所选值,不知道为什么.

asp.net-mvc asp.net-mvc-3

9
推荐指数
2
解决办法
2万
查看次数

通过存储过程传递动态顺序

我正在创建下面的存储过程.

declare @PageNum as Int
declare @PerPageResult as Int
declare @StartDate as varchar(25)
declare @EndDate as varchar(25)
declare @SortType as Varchar(50)
declare @SortDirection as Varchar(4)
set @PageNum=1
set @PerPageResult=20
set @StartDate='2008-02-08'
set @EndDate='2015-02-08'
set @SortType='RegDate'
set @SortDirection='Desc'
declare @Temp Table(RowNum int, RegDate Date, Registered int, Female int, Male int, [Join] int, Rebill int, TotalPointsEarned int, Expire int)
declare @sort varchar(50)
Insert into @Temp
    Select ROW_NUMBER() over (order by @SortType+' '+@SortDirection) As RowNum, * From (    
    SELECT 
    CAST(m.registrationdate AS Date) as …
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2008-r2

9
推荐指数
1
解决办法
3万
查看次数

.Net Core 主机进程 Windows 2016 IIS 中的高 CPU 使用率在 Asp.Net Core 2.2 应用程序中

我在 Asp.Net Core 2.2 中开发了一个网站,并托管在 IIS 中的 Azure VM(Windows Server 2016 数据中心)上。

我观察到,当我访问该网站时,经过几次请求,它的 CPU 使用率达到 100%,并且网站没有响应。当我终止进程(.Net Core Host)时,网站工作正常,然后进程再次消耗 100% CPU。

在此处输入图片说明

我在这方面搜索了很多,但没有找到解决方案。很多人都在为此受苦,并且仍在挣扎。

有没有人遇到过这个问题并找到了解决方案或任何解决方法?如果我的应用程序解决了问题,我愿意升级(核心 3.0)或降级(2.0)。

任何帮助将非常感激。

编辑:在搜索之后,我开始知道这个https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/690#issuecomment-399046332

那个人降级了应用核心v2.1,解决了cpu使用率高的问题。

.net iis asp.net-mvc asp.net-core asp.net-core-2.0

8
推荐指数
1
解决办法
7123
查看次数

Paypal自适应支付返回网址是两次调用

我已经实现了paypal自适应支付方法和使用网络流程.付款后,当我明确点击返回按钮时,返回网址会调用两次,但如果我等待自动重定向,则只调用一次.

我无法理解为什么返回网址会调用两次.

请指教.

我正在使用下面的代码.

public static ActionOutput MakeTransactionUsingPaypal(PaymentDetails payment, ShopCart shop_cart)
{
    ReceiverList receiverList = new ReceiverList();
    receiverList.receiver = new List<Receiver>();
    string action_type = "PAY_PRIMARY";
    decimal amnt_to_admin = ((shop_cart.TotalAmountToBePaid * 10) / 100);

    /*Total Amount to Admin Account */
    Receiver rec1 = new Receiver(shop_cart.TotalAmountToBePaid);
    rec1.email = Config.AdminPaypalBusinessAccount;
    rec1.primary = true;

    /*Amount after deducting to Admin Commision to Seller */
    Receiver rec2 = new Receiver(Math.Round((shop_cart.TotalAmountToBePaid - amnt_to_admin), 2, MidpointRounding.ToEven));
    rec2.email = payment.PaypalEmail; // "anuj_merchant@xicom.biz";

    receiverList.receiver.Add(rec1);
    receiverList.receiver.Add(rec2);
    PayRequest req = new PayRequest(new …
Run Code Online (Sandbox Code Playgroud)

asp.net paypal payment-gateway paypal-adaptive-payments

7
推荐指数
1
解决办法
1283
查看次数

在WebAPI中获取Microsoft.AspNet.WebApi.Cors版本问题

我在我的WebApi项目(.net framework 4.5.2)中安装了Microsoft.AspNet.WebApi.Corspackage Install-Package Microsoft.AspNet.WebApi.Cors,现在我在编译项目时遇到了错误.

参考:http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api

程序集'System.Web.Http.Cors,Version = 5.2.3.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'使用'System.Web.Http,Version = 5.2.3.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35',它有更高的版本比引用程序集'System.Web.Http,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'

.net asp.net-mvc web-services cross-domain asp.net-web-api

6
推荐指数
1
解决办法
6143
查看次数

什么确切的命令是在离线RHEL上安装pm2

首先,这不是一个重复的问题: -

如何在脱机服务器上安装npm -g

/sf/ask/2868327031/

我在我的离线REHL服务器上安装了npmbox(https://github.com/arei/npmbox),但我仍然不知道如何使用它安装pm2或任何其他软件包.

请指教.

linux ubuntu redhat node.js pm2

6
推荐指数
1
解决办法
8229
查看次数

获取"身份验证失败,因为远程方已关闭传输流".同时对UPS跟踪休息服务进行API调用

我正在我的asp.net mvc 5应用程序中实现UPS跟踪API.我创建了以下方法.

public virtual Core.UPSTrackingResponse.UPSTrackingResponse TrackUPS(string trackingNumber)
{
    Core.UPSTrackingRequest.UPSTrackingRequest requestModal = new Core.UPSTrackingRequest.UPSTrackingRequest();
    requestModal.UPSSecurity.ServiceAccessToken.AccessLicenseNumber = UPSAccessKey;
    requestModal.UPSSecurity.UsernameToken.Username = UPSUserId;
    requestModal.UPSSecurity.UsernameToken.Password = UPSPassword;
    requestModal.TrackRequest.InquiryNumber = trackingNumber;
    requestModal.TrackRequest.Request.RequestOption = "1";
    requestModal.TrackRequest.Request.TransactionReference.CustomerContext = trackingNumber + " tracking context";

    string Data = new JavaScriptSerializer().Serialize(requestModal);
    string response = "";
    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UPSTrackingURL); // https://wwwcie.ups.com/rest/Track
    request.Method = "POST";
    request.KeepAlive = false;
    request.ProtocolVersion = HttpVersion.Version10;

    request.ContentType = @"application/json";
    request.ContentLength = Data.Length;

    StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-mvc web-services ups

6
推荐指数
1
解决办法
7543
查看次数

如何从postgresql数据库生成edmx

我在postgresql中有一个数据库,我想在我的项目中使用vs 2010(v4.0)中的向导生成edmx(实体框架).

我按照本博客http://fxjr.blogspot.in/2011/05/npgsql-design-time-support-preview.html中给出的所有步骤进行了操作, 但在生成edmx时我找不到postgresql的数据提供程序.

我也见过http://ud-csharp.blogspot.in/2010/02/entity-framework-con-postgresql.html,但没有取得任何成功.

.net entity-framework npgsql asp.net-mvc-3

5
推荐指数
1
解决办法
3590
查看次数

动态地使用字符串绑定对象属性

我有一个下面的课

public class SearchModel
{
    public string Locations { get; set; }
    public string City { get; set; }
    public string Address { get; set; } 
    public string MaxRecord { get; set; }
    public string PageSize { get; set; }
    ....
    ....
    Approx 80 properties
}
Run Code Online (Sandbox Code Playgroud)

我有一个查询字符串 "my location_Locations/new york_City/city street_Address/200_MaxRecord/20_PageSize"

上面的字符串包含类的确切属性名称SearchModel.现在我想做以下事情: -

SearchModel model = new SearchModel();
string[] Parameters = "my location_Locations/new york_City/city street_Address/200_MaxRecord/20_PageSize".Split('/');
foreach (string item in Parameters)
{
    string[] value=item.Split('_');
    model.value[1] = value[0];
}
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net asp.net-mvc

5
推荐指数
1
解决办法
1173
查看次数

即使 url 是新的,浏览器也不会下载更新的 css、js 等

我在 asp.net mvc 4 中开发了一个 web 应用程序,我在其中提供一些资源文件,如 css、js、图像等。

为了始终提供更新的文件,我将一个随机字符串附加到查询字符串中。当我发布应用程序时,该查询字符串值会发生变化。因此,每个发布活动都会更改该字符串。

但是即使更改了 URL,浏览器也不会下载文件。浏览器第一次下载文件,并且总是从缓存的副本中提供服务。下面是我的代码。

<script src="~/Content/js/userdefined/dashboard.js?t=@Constants.RandomString" defer></script>

public static class Constants
{
    public static readonly string RandomString = Guid.NewGuid().ToString().ToLower();
}
Run Code Online (Sandbox Code Playgroud)

因此,每次发布应用程序时,它都会生成一个按预期工作的新字符串。

任何人都可以提供帮助,例如为什么即使 url 更改,浏览器也不下载更新的文件?

html asp.net iis browser-cache

5
推荐指数
1
解决办法
117
查看次数