这是我的控制器,我发送我的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.请任何人帮忙,谢谢
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闭环
我有一个 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)
但这不起作用,即使图像在那里,此事件被触发,并且我没有找到图像图像我做错了什么吗?请帮忙
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) 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) 我正在尝试使用 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 没有绑定作用域变量吗??..
我编写了一个自定义异常过滤器来记录我的应用程序异常,异常发生后我想将用户重定向到错误页面下面是我的代码
我的代码工作得很好,它捕获了异常,但在记录后它并没有将我扔到错误页面,你能帮忙吗
我的 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) asp.net ×3
c# ×3
javascript ×3
html ×2
angular ×1
angular6 ×1
angularjs ×1
asp.net-mvc ×1
biometrics ×1
closures ×1
exception ×1
image ×1
jquery ×1
ng-bind-html ×1
routing ×1
sanitize ×1
sql ×1