【发布时间】:2018-03-06 17:54:18
【问题描述】:
对于管理员:我在这里检查了类似的主题,但很遗憾我没有找到答案。
我正在尝试从 http GET 响应中删除所有 html 标记。 我有一个用 ASP.NET MVC 编写的控制器,它调用一个数据库过程。这些过程返回存在 html 标记的 json。 应用程序是用 Angular4 框架编写的。 我认为剥离所有 html 标签并用这个标签替换它们的最佳位置是什么:
& --> &
< --> <
> --> >
" --> "
' --> ' ' not recommended because its not in the HTML spec (See: section 24.4.1) ' is in the XML and XHTML specs.
/ --> / forward slash is included as it helps end an HTML entity
MS SQL 数据库中的过程以这种方式返回 JSON 数据:
SELECT * FROM USERS FOR JSON AUTO
MVC 控制器接收到这个字符串并返回给应用程序:
object response= ExecuteProcedure("GetAllUsers");
return response;
在应用程序中我这样调用 API:
getJson(url: string): Observable<any> {
return this.http.get(url).map(res => res.json()).catch(this.handleError);
}
让我感到困惑的是,为什么 XSS 在应用程序中不起作用,但在我直接从浏览器调用 API 时起作用。 我将不胜感激所有提示。
【问题讨论】:
-
你的 MSSQL 版本是多少?
-
我用的是 2017 版
标签: asp.net sql-server angular