ASP.NET

ASP.NET Testing Api controller: Uri(Request.GetEncodedUrl()…) returns null

帅比萌擦擦* 提交于 2021-02-19 07:43:49
问题 I am testing an ASP.NET Core Api post method, but I get a System.NullReferenceException causing my test to fail. The null exception appears when I try to return a Created()-ActionResult, like this: return Created(new Uri(Request.GetEncodedUrl() + "/" + personDto.Id), personDto); My personDto.Id nor the personDto is not null, but the result of the Uri() returns null. I have googled but not found a solution, but I believe I have to mock the Uri()-method in some way (I am new to testing and asp

ASP.net core using an anchor tag to work like a form

十年热恋 提交于 2021-02-19 07:30:15
问题 I am using asp.net core razor engine. Is there a way to get an anchor tag to access my Create method like a form tag does. I tested my code using a form tag and it works, is there a way to have the anchor tag do the same? Here is my code <div id = "menu"> @model ecommerce.Models.Users <a asp-controller="Product" asp-action="Create" method="post" role="form">Test</a> // This is the anchor tag that I want to have the same behavior as the form tag below <form asp-controller="Product" asp-action=

ASP.net core using an anchor tag to work like a form

社会主义新天地 提交于 2021-02-19 07:30:08
问题 I am using asp.net core razor engine. Is there a way to get an anchor tag to access my Create method like a form tag does. I tested my code using a form tag and it works, is there a way to have the anchor tag do the same? Here is my code <div id = "menu"> @model ecommerce.Models.Users <a asp-controller="Product" asp-action="Create" method="post" role="form">Test</a> // This is the anchor tag that I want to have the same behavior as the form tag below <form asp-controller="Product" asp-action=

各种提权姿势总结

柔情痞子 提交于 2021-02-19 05:51:51
提权技巧 1.cmd拒绝访问就自己上传一个cmd.exe,自己上传的cmd是不限制后缀的,还可以是cmd.com cmd.txt cmd.rar等 2.net user不能执行有时候是net.exe被删除了,可以先试试net1,不行就自己上传一个net.exe 3.cmd执行exp没回显的解决方法:com路径那里输入exp路径 C:\RECYCLER\pr.exe ,命令那里清空(包括/c )输入 net user jianmei daxia /add 4.有时候因为监控而添加用户失败,试试上传抓取hash的工具,如PwDump7.exe,得到hash之后可以进行破解,建议重定向结果到保存为1.txt cmd /c c:\windows\temp\cookies\PwDump7.exe >1.txt ,在条件允许的情况下也可以用mimikatz直接抓明文 5.有时候权限很松,很多命令都可以执行,但是就是增加不上用户,这时候你就要考虑是不是因为密码过于简单或是过于复杂了 6.用wt.asp扫出来的目录,其中红色的文件可以替换成exp,执行命令时cmd那里输入替换的文件路径,下面清空双引号加增加用户的命令 7.有时候可以添加用户,但是添加不到管理组,有可能是administrators组改名了,使用命令 net user administrator 查看管理组的名字 8

Dynamically adding js to asp.net file

梦想的初衷 提交于 2021-02-19 05:09:41
问题 In my Page_Load I identify the page header block from my master page and add javascript from an XML file to that part of the page. It doesn't seem to be loading in time. If I explicitly put the script reference on the page, it works. But not when I load through the page_load event. Should it be loaded sooner? 回答1: You're not adding any code so I'm not able to tell you what you're doing wrong. Instead, I'll tell you a valid way to add script references from code behind. Something like this on

ajax send request with encoding gzip is not working

那年仲夏 提交于 2021-02-19 03:56:53
问题 Ajax send request with encoding gzip (iis7) is not working below are the code for send request can some one help me what is wrong in my code. Thanks in advance function sendRequest(url, callback, postData) { var req = createXMLHTTPObject(); if (!req) { return; } var method = (postData) ? "POST" : "GET"; req.open(method, "xml/" + url, true); req.setRequestHeader('User-Agent', 'XMLHTTP/1.0'); if (postData) { req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); req

Passing JSON Object and List of Objects to ASP.Net Controller [duplicate]

做~自己de王妃 提交于 2021-02-19 03:38:12
问题 This question already has answers here : Post JSON array to mvc controller (3 answers) Closed 5 years ago . I need some help with the hereunder please. I have these 2 models and the method I will be using them in hereunder. public class RoleModel { public string Name { get; set; } public string Description { get; set; } public List<PermissionGroupModel> PermissionGroups { get; set; } } public class PermissionGroupModel { public int PermissionGroupID { get; set; } public string Name { get; set

如何使用Serilog.AspNetCore记录ASP.NET Core3.0的MVC属性

你说的曾经没有我的故事 提交于 2021-02-19 03:23:27
https://www.cnblogs.com/yilezhu/p/12243984.html 这是Serilog系列的第三篇文章。 第1部分-使用Serilog RequestLogging减少日志详细程度 第2部分-使用Serilog记录所选的终结点属性 第3部分-使用Serilog.AspNetCore记录MVC属性(本文) 第4部分-从Serilog请求记录中排除运行状况检查端点 作者:依乐祝 译文地址: https://www.cnblogs.com/yilezhu/p/12243984.html 原文地址: https://andrewlock.net/using-serilog-aspnetcore-in-asp-net-core-3-logging-mvc-propertis-with-serilog/ 在我 上篇文章 中,我描述了如何配置Serilog的RequestLogging中间件以向Serilog的请求日志摘要中添加其他属性(例如请求主机名或选定的端点名称)。这些属性都在 HttpContext 中可用,因此可以由中间件本身直接添加。 其他属性,例如MVC特定的功能,像操作方法ID,RazorPages处理程序名称或ModelValidationState, 仅 在MVC上下文中可用,因此Serilog的中间件不能直接访问。 在本文中,我将展示如何创建

EF Code First Project Doesn't Create AspNetUsers, AspNetRoles etc Tables after changing DB Connection

感情迁移 提交于 2021-02-19 02:47:06
问题 I've finished an EF Code First Project with a SQL Express database in a lab environment. Once the project is done, I've changed the DB Connection String to connect to the new Production SQL Express Database. Now, I have got the Model tables generated automatically but the AspNetUsers, AspNetRoles, AspNetUserRoles etc. are not generated automatically. I am a new learner and I need your help to know how I can get the tables back in the database. If I do update-database from the Package Manager

Autofac ASP.NET Web API (Beta) Integration

╄→гoц情女王★ 提交于 2021-02-19 01:57:36
With the beta release of ASP.NET MVC 4 and the ASP.NET Web API being released a few weeks ago, I decided it was about time to have a look at what the integration story would like for Autofac. The package is available for download on NuGet. Install-Package Autofac.WebApi2 -Version 4.2 . 0 While building the preview of the Web API integration I had the following goals in mind: Ensure that it would work alongside the MVC integration without issues such as naming conflicts. Support both the web hosting and self hosting scenarios in a single assembly. Avoid taking dependencies on the System.Web