小编Par*_*tte的帖子

ASP.NET MVC Core WebAPI项目不返回html

这是我的控制器,我发送我的HTML

      public class MyModuleController : Controller
        {
            // GET: api/values
            [HttpGet]
            public HttpResponseMessage Get()
            {


                var response = new HttpResponseMessage();
                response.Content = new StringContent("<html><body>Hello World</body></html>");
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
                return response;
            }
}
Run Code Online (Sandbox Code Playgroud)

作为回应我得到了这个

    {"version":{"major":1,"minor":1,"build":-1,"revision":-1,

"majorRevision":-1,"minorRevision":-1},"content":{"headers":[{"key":"Content-Type","value":["text/plain;

 charset=utf-8"]}]},"statusCode":200,"reasonPhrase":"OK","headers":[],"requestMessage":null,"isSuccessStatusCode":true}
Run Code Online (Sandbox Code Playgroud)

我只想输出我的html.请任何人帮忙,谢谢

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

8
推荐指数
2
解决办法
6931
查看次数

在Javascript中重复关闭

在此输入图像描述

function buildList( list ) {
  var i      = 0;
  var first  = function () {
    console.log( "in" )
    console.log( i );
  }
  var Second = function () {
    console.log( "out" )
    first();
  }
  return Second;
}

var a = buildList( [1, 2, 3] )
console.dir( a );

a(); // Here closure is created which has function first ,Here first also has one closure of itself that means recursive closure
Run Code Online (Sandbox Code Playgroud)

当我在Chrome中看到我的控制台时,它有一个闭包,它首先有一个函数,它本身就有一个闭包,即它有关闭时自身功能的重复循环,有没有人知道这里发生了什么,我很困惑,为什么有infinte闭环

javascript closures lexical-closures lexical-scope

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

addEventListener onerror 和错误事件不起作用

我有一个 asp.net 控件,它通过重复控件动态加载。如果未加载图像 src 或在图像元素上触发错误事件,我只想要一个替代图像,但它不起作用

<asp:Image ID ="test1" ImageUrl="test1.jpg"  runat="server" CssClass="NotFoundMain" />
<asp:Image ID ="test2" ImageUrl="test14.jpg"  runat="server" CssClass="NotFoundMain" />

 $(document).ready(function () {

        function callImageError(test) {
            console.log(test)
            alert()
        test.setAttribute('src', './Image/WebSiteImage/ImageNotAvailable.jpg');
    }

    function gotImageElement(item) {
        item.addEventListener('onerror', callImageError(item));
//        item.onerror(callImageError(item))
    }

    var mImg = document.getElementsByClassName("NotFoundMain");
    for (var i = 0; i < mImg.length; i++) {
            gotImageElement(mImg[i])
        }
        //mImg.forEach(gotImageElement)
    });
Run Code Online (Sandbox Code Playgroud)

但这不起作用,即使图像在那里,此事件被触发,并且我没有找到图像图像我做错了什么吗?请帮忙

javascript asp.net jquery image

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

来自数据库的数字角色指纹验证不起作用

   Device  :  Digital Persona u.are.u 4500 
Run Code Online (Sandbox Code Playgroud)

在注册时,我将数据以image格式保存在 sql 数据库中(sql 数据类型是图像)它工作正常我的数据正确保存在数据库中,但是现在当我在验证过程中验证数据时,它给出了异常

hresult : 0xffff.
Run Code Online (Sandbox Code Playgroud)

这是我用于验证的 C# 代码

SqlConnection conn = new SqlConnection(connetionstring);
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM mySavedDataTable", conn);
MemoryStream ms;
byte[] fpBytes;
SqlDataAdapter sd = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sd.Fill(dt);

foreach (DataRow dr in dt.Rows)
{
    fpBytes = Encoding.UTF8.GetBytes(dr["Template"].ToString());
    ms = new System.IO.MemoryStream(fpBytes);
    DPFP.Template template = new DPFP.Template();
    template.Serialize(ms);
    Verificator.Verify(features, template, ref result);
    if (result.Verified)
    {
        ver = true;
        break;
    }
} …
Run Code Online (Sandbox Code Playgroud)

c# sql biometrics digital-persona-sdk

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

当 skiplocationchange 为真时返回 Angular 6

Angular 6 中的路由

当我路由到特定位置时,我会导航

route.navigate(['/home'], { skipLocationChange: true });
Run Code Online (Sandbox Code Playgroud)

但是当返回到以前的路线时,下面的代码没有帮助,有没有其他方法或应该删除“{skipLocationChange:true}”

import {Component} from '@angular/core';
import {Location} from '@angular/common';

@Component({
  // component's declarations here
})
class SomeComponent {

  constructor(private _location: Location) 
  {}

  backClicked() {
    this._location.back();
  }
}
Run Code Online (Sandbox Code Playgroud)

html javascript routing angular angular6

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

ng-bind-html 不适用于我的 $scope.variable

我正在尝试使用 ng-bind-html 添加类似动态 HTML 的内容,但它不适用于 $scope 变量

这是我的 Angular 代码

1)我的控制器

$scope.name = "Parshuram"
$scope.thisCanBeusedInsideNgBindHtml = $sce.trustAsHtml("<div>{{name}}</div>");
Run Code Online (Sandbox Code Playgroud)

另外我的字符串是动态的

"<div><table class=" + "\"table table - bordered table - responsive table - hover add - lineheight table_scroll\"" + "><thead><tr><td>Name</td><td>Age</td></tr></thead><tbody><tr ng-repeat=" + "\"tr in dyna\"" + "><td>{{tr.name}}</td><td>{{tr.age}}</td></tr></tbody></table></div>"
Run Code Online (Sandbox Code Playgroud)

所以我不能用 $scope 替换每个变量

2)- 我的 HTML

<div ng-app="mymodule" ng-controller="myModuleController">
    <div ng-bind-html="thisCanBeusedInsideNgBindHtml"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我得到了这个输出

{{name}}
Run Code Online (Sandbox Code Playgroud)

我的预期输出是

Parshuram
Run Code Online (Sandbox Code Playgroud)

请任何人都可以帮助我卡在这一点上,$sce 没有绑定作用域变量吗??..

html sanitize angularjs ng-bind-html

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

ASP.NET MVC5 异常后重定向到 ErrorPage

我编写了一个自定义异常过滤器来记录我的应用程序异常,异常发生后我想将用户重定向到错误页面下面是我的代码

我的代码工作得很好,它捕获了异常,但在记录后它并没有将我扔到错误页面,你能帮忙吗

我的 CustomException Filer 类

public class CustomExceptionFilterAttribute : HandleErrorAttribute
{
    public override void OnException(ExceptionContext filterContext)
    {
        try
        {
            string requestBody = "", Action = "", Controller = "";

            try 
            {
                requestBody = filterContext.HttpContext.Request.Form.ToString();
                        Action = filterContext.RouteData.Values["action"].ToString();
                        Controller = filterContext.RouteData.Values["controller"].ToString();
            }
            catch (Exception)
            {
            }

            StringBuilder sbHeader = new StringBuilder();
            sbHeader.AppendLine(filterContext.RequestContext.HttpContext.Request.Headers.ToString());
            StaticMethods.LogException(SessionHelper.LoginCode.ToString(), Action, Controller, filterContext.Exception.Message, filterContext.RequestContext.HttpContext.Request.RawUrl.ToString(), requestBody, sbHeader.ToString());

            // This is which i am more concern about
            filterContext.RouteData.Values.Add("Error", filterContext.Exception.Message);
            filterContext.Result = new RedirectToRouteResult(
                                       new RouteValueDictionary(new { controller = "Error", …
Run Code Online (Sandbox Code Playgroud)

c# asp.net exception asp.net-mvc-5

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