我正在使用Mailgun API.我需要为他们提供一个URL,然后他们将向我发送HTTP一些数据.
我将此URL(http://test.com/MailGun/Webhook.aspx)提供给Mailgun,以便他们可以发布数据.我有一个他们发送的参数名称列表(收件人,域,IP,...).
我不确定如何在我的页面中发布该数据.在Webhook.aspx页面中,我尝试了一些代码如下,但所有代码都是空的.
lblrecipient.text= Request.Form["recipient"];
lblip.Text= Request.Params["ip"];
lbldomain.Text = Request.QueryString["domain"];
Run Code Online (Sandbox Code Playgroud)
不确定要尝试获取发布的数据?
我需要HTTP将XML数据发布到具有名称为XMLdata的Textarea的URL.我的XMl数据已准备就绪,位于XDocument Sendingxml = xml中; 但是我试过的邮政编码不起作用.主要是因为我不知道如何将XML数据放在postData变量中,因为它只接受字符串.这是我的代码:
XDocument Sendingxml = xml;
// string Sendingxml = "<?xml version=1.0 encoding=UTF-8> <PluginData> <Credential UserName=avosfieldagent01 AuthenticationToken=61cc3957744742dca238c4dd7cbca702 /><Session><PropertyAddress>5 Crosskey</PropertyAddress><PropertyAddress2/><PropertyCity>California</PropertyCity><PropertyState>CA</PropertyState><PropertyZip>92620</PropertyZip><PropertyType>Condo</PropertyType><SourceReferenceId>45643</SourceReferenceId><SessionId>2013070100158346</SessionId><SessionCompleteReturnURL/><CustomerId/><BluebookOrderCheckSum>681a598cf23f412095f6092c281823e6</BluebookOrderCheckSum><BluebookOrderId>11160</BluebookOrderId> </Session></PluginData>";
// Create a request using a URL that can receive a post.
WebRequest request =
WebRequest.Create("https://test.bluebookcva.net/order/testdirectplugin/3");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "XMLData=" + Sendingxml; //My problem is here as I need postData as XDocument.
byte[] …Run Code Online (Sandbox Code Playgroud) 我需要在SQL中创建一个ID作为Guid(没有身份)我怎么能这样做?我将Id定义为uniqueidentifier,但在Db中保存的是00000000-0000-0000-0000-000000000000
我从存储库调用Web API(C#)中的方法.该方法是存储库没有返回任何东西.这是虚空.我应该在API方法中返回,因为async方法不能有Void返回类型.
这是我在API中的Async方法:
[HttpPost]
[Route("AddApp")]
public async Task<?> AddApp([FromBody]Application app)
{
loansRepository.InsertApplication(app);
}
Run Code Online (Sandbox Code Playgroud)
这是EntityFrame工作在存储库中插入(我可以通过这种方式改变这个)
public void InsertApplication(Application app)
{
this.loansContext.Application.Add(app);
}
Run Code Online (Sandbox Code Playgroud)
对不起,我对这个问题做了修改,我不知道该怎么办?在任务中
我需要将Grid.MVC中的数据导出到Excel。我在此链接中使用了解决方案。
http://www.codeproject.com/Articles/325103/MVC-Grid-to-Excel-file-download?msg=5161340#xx5161340xx
它正在工作,但是我有2个问题。首先,它在chrome中工作,但在IE中不工作。它给我一个错误(无法读取文件)在IE中。第二个问题是,当我过滤网格时,Excel中的导出数据仍然显示所有数据,而不是过滤后的数据。
如果这不是一个好的解决方案,请提供我将Grid.MVC数据导出到excel的示例。
我需要从控制器发送一些值到共享视图以显示在顶部
[HttpPost]
[Route("login")]
public async Task<ActionResult> Login(LogInRequest logInRequest)
{
IEnumerable<UserClaim> UserClaims = null;
User user = null;
if (ModelState.IsValid)
{
user = await GetUserByEmailAndPassword(logInRequest.UserName, logInRequest.Password);
if (user.Id != 0)
{
showMenu = await ShowLoanMenu(logInRequest);
if (showMenu)
{
******** I need to send showMenu and user.Name to shared view
return RedirectToAction(Constants.Views.SearchView, Constants.Views.LoanDriverController);
}
}
.....
return View(logInRequest);
}
Run Code Online (Sandbox Code Playgroud)
我不想使用TempData,viewdata,viewbag或session,我如何通过查询字符串或添加到模型来发送它.
这是布局之一:
<ul>
<li class="logo">
<img src="~/Content/Images/logo.png" alt="" />
</li>
<li class="nav-item">
*** @if(showmenu is true)
{
<ul>
@Html.ActionLink("Loan Driver", "Index", "Home", new …Run Code Online (Sandbox Code Playgroud) 如何添加测试Cookie以请求,以便可以从单元测试中测试代码。考虑这样的代码:
public ActionResult Dashboard()
{
if (Request.Cookies["usercookie"] == null)
{
return RedirectToAction("Index");
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
我模拟了所有内容,但是我不知道如何向Cookie添加内容,因此该行Request.Cookies["usercookie"]不会返回null。现在它为null并返回此错误:
{“你调用的对象是空的。”}
这是我的单元测试方法之一:
[TestMethod]
[TestCategory("Unit")]
public void Login_ShouldValidateUserAndLoginSuccessfully()
{
using (var kernel = new NSubstituteMockingKernel())
{
// Setup the dependency incjection
kernel.Load(new EntityFrameworkTestingNSubstituteModule());
// Create test request data
var request = new LogInRequest { UserName = "test", Password = "test" };
var fakeResponseHandler = new FakeResponseHandler();
fakeResponseHandler.AddFakeResponse(new Uri("http://localhost/test"), new HttpResponseMessage(HttpStatusCode.OK));
ConfigurationManager.AppSettings["SearchApiBaseUrl"] = "http://test/internal";
var server = new HttpServer(new HttpConfiguration(), fakeResponseHandler);
var httpClient …Run Code Online (Sandbox Code Playgroud) 我需要迭代这个 Json 数据并在 JavaScript(TypeScript) No Jquery 中向网格添加值。
{"GridHeader":{"Id":"Id","Name":"Full Name","Age":"Age"},"GridData":{"Id":3,"name":"Vu","age":34}}
Run Code Online (Sandbox Code Playgroud)
我有如下添加函数,它将标题和数据添加到网格:
let header = '{"GridHeader":{"Id":"Id","Name":"Full Name","Age":"Age"},"GridData":{"Id":3,"name":"Vu","age":34}}';
let myheader = JSON.parse(header);
for (var i = 0; ??) {
....
AddRecord(headerdata, i);
}
Run Code Online (Sandbox Code Playgroud)
这是我将它添加到网格的地方:
function AddRecord(record, n) {
var detail = document.getElementById("detail");
var header = document.getElementById("header");
if (n == 0) {
var newdiv = document.createElement("div");
newdiv.innerHTML = "<div style=''>" + record.id + "</div>" + "<div>" + record.name + "</div>" + "<div>" + record.age + "</div>";
}
var newdiv = document.createElement("div");
newdiv.innerHTML = "<div …Run Code Online (Sandbox Code Playgroud) 我在C#和Framework 6中有一个项目。我有一个Web API来调用方法。为异步WebAPI方法编写单元测试的最佳方法是什么?
这是我有的方法:
[HttpGet]
[Route("GetYears")]
public async Task<IEnumerable<Year>> GetYears()
{
IEnumerable<Year> newYears;
newYears = await creditApplicationsRepository.GetYearsAsync();
return newYears;
}
Run Code Online (Sandbox Code Playgroud) 我在C#中有一个Async方法,它调用返回true或false的SQL函数,方法返回true或false的bool变量.
这是我的方法:
public async Task<bool> Canlog(string userName, string pass
{
Context context = new Context();
bool queryResult = false;
using (context )
{
using (context .Database.Connection)
{
context .Database.Connection.Open();
string sqlStatment = .....
queryResult = authorizationContext.Database
.SqlQuery<bool>(sqlStatment)
.Single();
}
}
return await queryResult;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,我在这行返回错误await queryResult,无法等待bool.
c# ×7
asp.net-mvc ×3
unit-testing ×2
asp.net ×1
cookies ×1
http-headers ×1
http-post ×1
javascript ×1
nsubstitute ×1
sql ×1
sql-server ×1
typescript ×1
xml ×1