小编Ger*_*cke的帖子

无法将带有[]的索引应用于mvc控制器中类型为'System.Collections.Generic.ICollection <int>的表达式

public ActionResult addstandardpackage1(ICollection<int> SingleStay,ICollection<int> DOUBLESTAY,ICollection<int> TRIBLESTAY,ICollection<int> FAMILYSTAY,ICollection<int> EXTRABED)
{
    var s = SingleStay;
    for (int i = 0; i < SingleStay.Count; i++ )
    {
        var cal = SingleStay[i];
    }
    foreach (var key in SingleStay)
    {
        var value = key;
    }          

}
Run Code Online (Sandbox Code Playgroud)

在for循环中,我得到的错误就像无法将带有[]的索引应用于类型的表达式但是我需要for for循环,对于我得到的每一个.因为基于for循环我会将细节与其他集合列表绑定.请帮我.

我收到了错误var cal=Singlestay[i].

c# model-view-controller

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

使用jQuery Ajax将参数传递给WebMethod

我有一个简单的Web方法和ajax调用,并继续收到一个错误,说它无法将字符串转换为IDictionary对象???

这是ajax调用:

var params = '{"ID":"' + rowid + '"}';
$.ajax({
  url: 'EDI.asmx/GetPartnerDetails',
  type: "POST",
  contentType: "application/json; charset=utf-8",
  data: JSON.stringify(params),
  dataType: "json", //not json . let me try to parse
  success: function(msg, st) { . . . .
Run Code Online (Sandbox Code Playgroud)

这是webMethod:

<WebMethod()> _
Public Function GetPartnerDetails(ByVal ID As String) As String

    'Dim objParam As IDictionary = CType(JsonConvert.DeserializeObject(ID), IDictionary)
    'Dim rowID As String = objParam("ID")

    Dim objController As New HealthComp.BLL.X12Partners.TradingPartnersController
    Dim objInfo As TradingPartnersInfo = objController.FetchByPartnerID(Int32.Parse(ID))

    Return JsonConvert.SerializeObject(objInfo)
End Function
Run Code Online (Sandbox Code Playgroud)

这是我从FireBug看到的:

响应标头
服务器:Microsoft-IIS/5.1 …

asp.net parameters jquery json web-services

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

无法将lambda表达式转换为类型'System.Delegate',因为它不是委托类型?

我遇到了一个我似乎无法弄清楚的问题,尽管它在Stackoverflow上有一个标准问题.

我正在尝试使用以下代码异步更新我的Bing地图(请注意,这是来自旧的Silverlight项目,似乎在WPF中不起作用)

_map.Dispatcher.BeginInvoke(() =>
{
    _map.Children.Clear();
    foreach (var projectedPin in pinsToAdd.Where(pin => PointIsVisibleInMap(pin.ScreenLocation, _map)))
    {
        _map.Children.Add(projectedPin.GetElement(ClusterTemplate));
    }
});
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c# wpf delegates

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

NextJS 公共环境变量不适用于 Azure 应用服务

我的 NextJS 应用程序中有一个NEXT_PUBLIC环境变量。它已在我的.env.local文件中设置并正常工作,但在将其部署到 Azure 应用服务后,应用程序无法读取它。它是“未定义”。我已在应用程序服务的配置下对其进行了配置。在此输入图像描述

关于可能出现的问题有什么建议吗?

提前致谢。

environment-variables azure azure-web-app-service next.js

12
推荐指数
1
解决办法
3111
查看次数

在C#中调用google Url Shortner API

我想从我的C#控制台应用程序中调用google url shortner API,我尝试实现的请求是:

POST https://www.googleapis.com/urlshortener/v1/url

Content-Type:application/json

{"longUrl":" http://www.google.com/ "}

当我尝试使用此代码时:

using System.Net;
using System.Net.Http;
using System.IO;
Run Code Online (Sandbox Code Playgroud)

主要方法是:

static void Main(string[] args)
{
    string s = "http://www.google.com/";
    var client = new HttpClient();

    // Create the HttpContent for the form to be posted.
    var requestContent = new FormUrlEncodedContent(new[] {new KeyValuePair<string, string>("longUrl", s),});

    // Get the response.            
    HttpResponseMessage response = client.Post("https://www.googleapis.com/urlshortener/v1/url",requestContent);

    // Get the response content.
    HttpContent responseContent = response.Content;

    // Get the stream of the content.
    using (var reader …
Run Code Online (Sandbox Code Playgroud)

.net c# google-api httpwebrequest

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

用knockoutjs绑定bootstrap datepicker

我想使用bootstrap datepicker并将所选日期与knockoutjs绑定.

使用datepicker的函数:

$(function() {

    // create the departure date
    $('#depart-date').datepicker({
        autoclose: true,
        format: 'yyyy/mm/dd',
    }).on('changeDate', function(ev) {
        ConfigureReturnDate();
    });


    $('#return-date').datepicker({
        autoclose: true,
        format: 'yyyy/mm/dd',
        startDate: $('#depart-date').val()
    });

    // Set the min date on page load
    ConfigureReturnDate();

    // Resets the min date of the return date
    function ConfigureReturnDate() {
        $('#return-date').datepicker('setStartDate', $('#depart-date').val());
    }

});
Run Code Online (Sandbox Code Playgroud)

这是我想要使用的小提琴,但不知道如何去做. http://jsfiddle.net/zNbUT/276/

twitter-bootstrap knockout.js

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

命令退出时出现代码3错误

我想从VS2012转换到VS2015的项目.现在我得到以下错误,它第一次得到它所以我有点迷失在如何解决它或原因是什么.

严重级代码描述项目文件行抑制状态错误命令""C:\ Program Files(x86)\ Microsoft\ILMerge\ILMERGE.EXE"/ t:console /targetplatform:v4,%systemroot%\Microsoft.NET\Framework\v4 .0.30319 /out:BlobClient.exe StrikeMedia.BlobStorage.CmdLineTool.exe StrikeMedia.ServiceBus.dll StrikeMedia.BlobStorage.dll"退出,代码为3. StrikeMedia.BlobStorage.CmdLineTool

希望你能帮助我.

谢谢

visual-studio-2012 visual-studio-2015

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

带有Ninject的WebAPI

我遇到了麻烦,制作了Ninject和WebAPI.All合作.我将更加具体:
首先,我玩了WebApi.All包,看起来它对我来说很好.
第二,我加入RegisterRoutesGlobal.asax下一行:

routes.Add(new ServiceRoute("api/contacts", new HttpServiceHostFactory(), typeof(ContactsApi)));
Run Code Online (Sandbox Code Playgroud)

所以最终的结果是:


public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.Add(new ServiceRoute("api/contacts", new HttpServiceHostFactory(), typeof(ContactsApi)));

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory());

}
Run Code Online (Sandbox Code Playgroud)

一切似乎都很好,但是当我试图将用户重定向到特定的操作时,例如:

return RedirectToAction("Index", "Home");
Run Code Online (Sandbox Code Playgroud)

localhost:789/api/contacts?action=Index&controller=Home 是不好的.我划了一条线RegisterRoute,现在它看起来像:


public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new …
Run Code Online (Sandbox Code Playgroud)

c# ninject .net-4.0 asp.net-mvc-3

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

RedirecttoAction包含错误消息

我在AdminUsers视图中有一个网格链接

grid.Column(header: "", format: (item) => (condition ? Html.ActionLink("Impersonate", "Impersonate", "Admin", new { id = item.username }, null) : Html.Label("Impersonate"), style: "webgrid-column-link"),
Run Code Online (Sandbox Code Playgroud)

在控制器中,我有

public ActionResult Impersonate(string id)
{
    string result = ORCA.utilities.users.setImpersonation(id);
    if(result == "nocommonfields")
        return RedirectToAction("AdminUsers", "Admin");
    else
        return RedirectToAction("terms_of_use", "Forms");
}
Run Code Online (Sandbox Code Playgroud)

当我返回AdminUsers页面时,如何发送错误消息?

asp.net-mvc redirecttoaction

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

使用MVC Razor传递列表对象

我正在使用一个对象但在对象内部我有一个属性是一个对象列表.我希望将该对象与其中的列表对象一起传递,但是当我提交表单时列表为空.我不知道如何处理这个问题.

public class VSTAttendance
{
    public int MemberID { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
    public bool Attendant { get; set; }
}

public class ServiceAttendance 
{
    public int AttendanceID { get; set; }
    public int AttendanceTypeID { get; set; }
    public string AttendanceType { get; set; }
    public DateTime Service { get; set; }
    public int ServiceID { get; set; }
    public string Speaker { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc-4

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