小编Mik*_*rks的帖子

ColdFusion 9调用.NET Web服务 - 无法找到带参数的Web服务操作.救命!

错误:无法找到参数{part = {...},storeId = {...},contractId = {...}}的Web服务操作....

我创建了一个与ColdFusion页面对话的.NET Web服务.当用户在零件编号字段中键入零件编号然后从中选中标签时,会调用Web服务以获得该零件的适当定价.它是如何在幕后完成定价的,是无关紧要的,并且太复杂了,无法在这里展示我想要了解的重点.

这就是我发生的事情 - 我让ColdFusion页面传递了3个变量:part,storeIdcontractId.

<cfset vars = structNew()>
<cfset vars["contractId"] = "#Trim(Attributes.contract)#">
<cfset vars["part"] = "#Trim(Attributes.part)#">
<cfset vars["storeId"] = "#Trim(Attributes.store)#">

<cfinvoke webservice = "http://compassnetdev/Services/CustomerContractPartPrice.asmx?wsdl"
          method = "GetCustomerContractPrice"
          returnVariable = "price"
          argumentCollection = "#vars#">
</cfinvoke>

在此之前,我刚收到了contractId和传入的部分,并且效果很好.没问题.但是因为我在storeId中添加了,它会抛出这个错误消息:

Error Occurred While Processing Request  
Web service operation GetCustomerContractPrice with parameters {part={BV410070},storeId={001},contractId={21}} cannot be found.  


The error occurred in C:\inetpub\wwwroot\CustomTags\fn_get_price_2.cfm: line 58

56 …

.net coldfusion service

5
推荐指数
2
解决办法
3227
查看次数

在MVC4中,如何将文件(图像)上传到属于我的域模型的SQL Server?

我对MVC比较陌生,而且我从来不必处理将文件(特别是图像)上传到SQL Server数据库的问题.说实话,我不知道我在这里做什么.

以下是我到目前为止的内容 - 这是我的域模型(请注意HttpPostedFileBase我的模型 - 这是我要上传的内容):

public class Profile
{
    [Key]
    public int Id { get; set; }

    [Required(ErrorMessage="Years of service is required")]
    [DisplayName("Years Service:")]
    public int YearsService { get; set; }

    [DataType(DataType.MultilineText)]
    [DisplayName("Notable Achivements:")]
    public string NotableAchivements { get; set; }

    [Required(ErrorMessage = "Technical skills are required")]
    [DataType(DataType.MultilineText)]
    [DisplayName("Technical Skills:")]
    public string TechnicalSkills { get; set; }

    [DisplayName("Upload Image: ")]
    public HttpPostedFileBase Photo { get; set; }

    public string CreatedBy { get; set; }
    public DateTime …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net asp.net-mvc file-upload

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

Azure - web.config中的customErrors ="off"未显示Azure应用程序中的详细错误(云服务)

我有一个部署到Azure的应用程序,它使用ADFS(Active Directory联合服务)进行身份验证.

当用户尝试导航到Azure上的应用程序时,它会将用户重定向到ADFS身份验证页面.用户输入凭据并单击"确定",ADFS会将用户重定向到我的应用的登录页面.

到目前为止,一切都很好.一旦用户点击着陆页,我就会在应用上收到通用服务器错误. 问题:我需要查看详细错误. 我尝试设置<customErrors="off" />,重新打包我的应用程序并重新部署,但这不会给我详细的错误:

在此输入图像描述

这是我尝试过的:我尝试在调试模式下打包我的应用程序(在发布模式不起作用后),我编辑了web.config(在解决方案的根目录,以及在Views文件夹中) ,只是为了涵盖所有基地).没有任何效果.

我究竟做错了什么?

web-config azure custom-errors adfs2.0

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

使用ASP.NET WebAPI返回由Ajax GET请求使用的Boolean

我已经构建了一个返回的WebAPI(使用版本2)HttpResponseMessage.我AJAX向这些WebAPI方法发出请求,WebAPI返回JSON响应.这一切都很好,但现在我需要的是一种AJAX向WebAPI方法发出GET请求的方法,该方法只返回一个布尔值.这是GET我正在使用的请求示例JSON:

$.ajax({
    url: 'http://server/site/api/BulletinBoard/GetUserMessageHistory?userId=' + userId + '&messageId=' + messageId,
    type: 'GET',
    dataType: 'json',
    crossDomain: true,
    success: function (data) {
          DoSomething();                    
    },
    error: function (x, y, z) {
          alert(x + '\n' + y + '\n' + z);
    }
});
Run Code Online (Sandbox Code Playgroud)

我希望完成的是(这是伪代码):

    var hasMessageBeenDisplayed = 
        $.ajax({
              url: 'http://server/site/api/BulletinBoard/GetUserMessageHistory?userId=' + userId + '&messageId=' + messageId,
              type: 'GET',
              dataType: 'json',
              crossDomain: true,
              success: function (data) {
                   DoSomething();                    
              },
              error: function (x, y, …
Run Code Online (Sandbox Code Playgroud)

c# asp.net ajax jquery asp.net-web-api

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

为什么C#中需要"新"关键字

假设我有一个函数foo,它将vector类作为输入:

void Foo( Vector3 vector );
Run Code Online (Sandbox Code Playgroud)

如果我想调用此函数:

Foo( new Vector3(1, 2, 3) );
Run Code Online (Sandbox Code Playgroud)

为什么新关键字必不可少(在C#中)?

在其他语言中,例如:C++,在这种情况下不需要使用new .这似乎是多余的

编辑1:@prander以下是完全有效的C++

Foo ( Vector3(1, 2, 3) );
Run Code Online (Sandbox Code Playgroud)

将在堆栈上创建Vector3对象,不需要new/calloc/malloc.

c# keyword

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

DELETE/PUT谓词仅在本地运行时导致在WebAPI中找不到404 404

我知道这是一个常见的问题,我已经完成了很多关于SO的帖子.当我尝试从在本地IIS下运行的MVC5前端使用WebAPI(版本2)删除记录时,我得到404 Not Found响应.以下是我尝试过的事情:

<system.webServer />在我的WebAPI web.config中添加了以下内容:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

我按照以下说明操作:http://geekswithblogs.net/michelotti/archive/2011/05/28/resolve-404-in-iis-express-for-put-and-delete-verbs.aspx,基本上说要ExtensionlessUrlHandler-Integrated-4.0在IIS中修改"Handler Mappings".它说要双击处理程序,单击"请求限制"和"允许PUT和DELETE谓词".我做到了这一点,我仍然得到404错误.

我已经完成了IIS重置.

这里是我的MVC5前端代码调用的WebAPI删除方法-请注意,当我手动导航到api/bulletinboard/get/{0}那里{0}是一个整数,我得到一个有效的JSON响应.下面contactUrihttp://localhost/SiteName/api/bulletinboard/get/53哪个返回有效JSON:

[HttpPost, ActionName("Delete")]
        public ActionResult Delete(string appId, int id)
        {
            response = client.GetAsync(string.Format("api/bulletinboard/get/{0}", id)).Result;
            contactUri = response.RequestMessage.RequestUri;
            response = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net iis asp.net-mvc asp.net-web-api

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

第一次编写ASP.NET MVC应用程序需要绑定到SSRS并显示报告

嘿大家..这是我第一次编写ASP.NET MVC Web应用程序,而且它很顺利.我没有问题.我没有任何经验是SSRS.最终,我希望能够在我的ASP.NET MVC应用程序上呈现报告.

  1. 我安装并运行了报表服务器,它在SQL Server Management Studio中可见.
  2. 我通过Business Intelligence Development Studio创建了一个测试报告(.rdl),并将其发布到我的报告服务器.它现在在那里,我查了一下.

我的问题是如何将其与我的主应用程序联系起来?我是否必须在主应用程序中添加引用才能检索我创建的报告?我完全迷失了 - 我的主数据库和我的报表服务器都在SQL Server Management Studio中可见.就我而言......帮助???? 提前致谢..!

asp.net-mvc reporting reporting-services

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

尝试在我的WebAPI上调用特定的GET方法,但是找不到HTTP 404

我正在打电话http://localhost/AppTools.WebAPI/api/BulletinBoard/GetMessagesForApp/AppName,但它返回404错误.我认为这与路由有关,但我不确定.

这是我的BulletinBoard控制器中的Web API方法:

        [HttpGet]
        public HttpResponseMessage GetMessagesForApp(string id)
        {
            // get current, valid messages
            var messages = (from i in db.BulletinBoards 
                            where i.AppId == id &&
                            DateTime.Today >= i.DisplayFrom &&
                            DateTime.Today <= i.DisplayTo &&
                            i.IsActive == true
                            select new 
                            {
                                Message = i.Message,
                                IntervalId = i.IntervalId,
                                Interval = i.Interval.IntervalDescription,
                                Timeout = i.Timout,
                            })
            .ToList();

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, messages);
            return response;
}
Run Code Online (Sandbox Code Playgroud)

这是我的RouteConfig.cs:

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

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc routes asp.net-web-api

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

获取错误"建立与SQL Server的连接时发生与网络相关或特定于实例的错误..."

通常情况下,我能够解决这个问题.但是,我发现的是我有一个MVC4应用程序,在当前状态下,不会连接到任何类型的数据源.我相信开箱即用的MVC带有一些默认的数据连接属性.

这一点的重点是通过将一些数据值硬编码到应用程序本身来向我们的客户展示应用程序"可能"的样子.因此,运行应用程序会解决错误:

建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确,以及SQL Server是否配置为允许远程连接.(提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)

我需要删除我的应用程序中的任何SQL相关内容,我删除了web.config中已有的连接字符串.

问题:模板代码中的其他位置是否尝试建立SQL连接(假设它是基于错误而尝试做的)?

谢谢!

.net c# sql asp.net-mvc connection-string

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

以递归方式调用线程方法(System.Threading)是不好的做法吗?

原谅我的术语,我不是那么熟悉System.Threading,但如果我有类似下面的内容:

private static int _index;
private static List<int> _movieIds = new List<int>();

static void Main(string[] args)
{
    // the below call populates the _movieIds list variable with around 130,000 ints
    GetListOfMovieIdsFromDatabase(); 

    _index = 0;
    Thread myThread = new Thread(DoWork);
    myThread.Start();
}

public static void DoWork()
{
     // do something with the value of _index (iterate through the _movieIds list) then recursively call DoWork() again

     Thread.Sleep(400);

     _index++;

     DoWork();
}
Run Code Online (Sandbox Code Playgroud)

这是不好的做法吗?我正在迭代通过int's在类级别定义的私有静态列表作为成员,因此第一次迭代DoWork()将使用第一个值_index(以某种方式我没有为简单起见解释),然后是第二次迭代(递归调用)将使用第二个值_index,依此类推.

我问这个的原因是因为我在运行这个应用程序大约12个小时后出现了堆栈溢出异常,我相信这是因为递归调用.

c# recursion multithreading

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