未捕获的TypeError:无法使用'in'运算符搜索"length"中的"length"
这是我尝试$.each对此JSON对象执行此操作时收到的错误:
{"type":"Anuncio","textos":["Probando esto","$ 20150515"],"submit":"codParameters?___DDSESSIONID\u003d14EA4721A904D6DD71591156996E29F7%3A%2FMobilTest"}
Run Code Online (Sandbox Code Playgroud)
我也尝试用stringify做同样的事情,但是我收到了同样的错误:
{\"type\":\"Anuncio\",\"textos\":[\"Probando esto\",\"$ 20150515\"],\"submit\":\"codParameters?___DDSESSIONID\\u003d06CBEC9D1A53616EFF703A8C71FBC2B4%3A%2FMobilTest\"}"
Run Code Online (Sandbox Code Playgroud)
如果我___DDSESSIONID\\u003d06CBEC9D1A53616EFF703A8C71FBC2B4%3A%2FMobilTest从对象中删除参数,$ .each工作正常.
为什么会发生这种情况?
提前致谢.
我正在尝试设置一个新的工作空间,并将我的所有项目从旧计算机转移到新计算机.但是,当我尝试运行IIS Express时出现此错误:
无法启动进程C:\ Program Files\dotnet\dotnet.exe.Web服务器请求失败,状态码为500.
我在Visual Studio 2015中工作,更新3,我使用的是.NET Core RC2.有没有人知道如何解决这个问题并让我的旧项目在这台新机器上运行?
我的视图中有一个HTML表格如下:
<table id="tblCurrentYear">
<tr>
<td>Leave Type</td>
<td>Leave Taken</td>
<td>Leave Balance</td>
<td>Leave Total</td>
</tr>
@foreach (var item in Model.LeaveDetailsList)
{
<tr>
<td>@Html.TextBoxFor(m => item.LeaveType, new { width = "100" })</td>
<td>@Html.TextBoxFor(m => item.LeaveTaken, new { width = "100" })</td>
<td>@Html.TextBoxFor(m => item.LeaveBalance, new { width = "100" })</td>
<td>@Html.TextBoxFor(m => item.LeaveTotal, new { width = "100" })</td>
</tr>
}
</table>
Run Code Online (Sandbox Code Playgroud)
我想遍历所有html表行并在ADO.NET DataTable中插入值.
简单来说,将HTML表转换为ADO.NET DataTable.
如何从HTML表中提取值并插入到ADO.NET DataTable中?
该视图基于以下模型
public class LeaveBalanceViewModel
{
public LeaveBalanceViewModel()
{
this.EmployeeDetail = new EmployeeDetails();
this.LeaveBalanceDetail = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试做一些简单而琐碎的事情-至少我认为。
我正在尝试编写一个基类,该基类可以由我启动的每个微服务项目继承。该基类的重点是测试从HTTP一直到SQL的连通性。PROD中未启用它。
这是(简单的)基类之一:
public class DevTestControllerBase: ApiControllerBase
{
public DevTestControllerBase(IHostingEnvironment env, IConfiguration configuration = null, IMediator mediator = null) : base(env, configuration, mediator)
{
}
[HttpGet]
public IActionResult Get()
{
var response = Mediator.Send(new QueryGet());
return Ok(response.Result);
}
[HttpGet("{id}", Name = "Get")]
public IActionResult Get(Guid id)
{
var response = Mediator.Send(new QueryGetById(id));
return Ok(response.Result);
}
[HttpPost]
public async Task<IActionResult> Post([FromBody]DevTestModelBinding value)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
var response = await Mediator.Send(new CommandPost(value));
return Created("Get", new { …Run Code Online (Sandbox Code Playgroud) 问题
我在使用OpenID Connect 3为我正在开发的网站提供授权时遇到问题。
问题是这样的:
第 4 步和第 5 步将永远进行下去……好吧,除了达到 cookie 最大数量的限制之外,一切都会结束。
尝试过的解决方案
经过几天的谷歌搜索后,我尝试了以下方法,但到目前为止没有任何效果对我有用。
Kentor Owin Cookie Fix在 Startup 类中..ConfigureAuth 函数
app.UseKentorOwinCookieSaver();
Run Code Online (Sandbox Code Playgroud)1 的变体
app.UseKentorOwinCookieSaver(PipelineStage.Authenticate);
Run Code Online (Sandbox Code Playgroud)替代 cookie 管理器SystemWebCookieManager
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
CookieManager = new SystemWebCookieManager()
});
Run Code Online (Sandbox Code Playgroud)3 SystemWebChunkingCookieManager的变体
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
CookieManager = new SystemWebChunkingCookieManager()
});
Run Code Online (Sandbox Code Playgroud)Global.asa 文件中的会话存根
protected void Session_Start()
{
}
protected void Session_End() …Run Code Online (Sandbox Code Playgroud)因此,我正在使用身份验证模板编辑默认的 ASP.NET MVC,并且我正在尝试为其创建一个 ViewModel _PartialLogin.cshtml,以便显示名称而不是用户的电子邮件。我搜索了很多东西,但它们已经过时了,所以我希望有人能提供帮助。我什至不知道创建 ViewModel 是否是最佳选择。
这是LoginPartialViewModel:
namespace AplicacaoRoles2.Models.SharedViewModels
{
public class PartialLoginViewModel
{
[Required]
public string Nome { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
_LoginPartial.cshtml:
@using Microsoft.AspNetCore.Identity
@using AplicacaoRoles2.Models
@model AplicacaoRoles2.Models.SharedViewModels.PartialLoginViewModel
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager
@if (SignInManager.IsSignedIn(User))
{
<form asp-area="" asp-controller="Account" asp-action="Logout" method="post" id="logoutForm" class="navbar-right">
<ul class="nav navbar-nav navbar-right">
<li>
<a asp-area="" asp-controller="Manage" asp-action="Index" title="Manage">Hello @Html.DisplayFor(model => model.Nome) !</a>
</li>
Run Code Online (Sandbox Code Playgroud)
(...)
HomeController:
public class HomeController : Controller
{
private readonly ApplicationDbContext _context; …Run Code Online (Sandbox Code Playgroud) 具有Method / Action ObtainValue时,我想在调用该方法时为该方法分配一个不同的名称,所以我使用ActionName属性
[ActionName("GetValueByID")]
public string ObtainValue(int id)
{
return "value";
}
Run Code Online (Sandbox Code Playgroud)
但是我也可以使用Route属性,如下所示
[Route("Api/Values/GetValueByID")]
public string ObtainValue(int id)
{
return "value";
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,有区别吗?应该使用其中一个?如果我同时使用两者,那该怎么办?
使用适用于.Net的AWS SDK,我可以使用以下方法在UserPool中注册用户
AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), RegionEndpoint.USEast1);
SignUpRequest signUpRequest = new SignUpRequest()
{
ClientId = CLIENTAPP_ID,
Password = user.Password,
Username = user.Username
};
await provider.SignUpAsync(signUpRequest);
Run Code Online (Sandbox Code Playgroud)
注册后,我想验证用户身份并登录并重定向到某个授权页面。使用以下代码我可以获得身份验证令牌
CognitoUserPool userPool = new CognitoUserPool(this.POOL_ID, this.CLIENTAPP_ID, provider);
CognitoUser user = new CognitoUser(username, this.CLIENTAPP_ID, userPool, provider);
InitiateSrpAuthRequest authRequest = new InitiateSrpAuthRequest()
{
Password = password
};
AuthFlowResponse authResponse = await user.StartWithSrpAuthAsync(authRequest).ConfigureAwait(false);
if (authResponse.AuthenticationResult != null)
{
// Here i can see authResponse.AuthenticationResult.AccessToken
}
Run Code Online (Sandbox Code Playgroud)
但现在对于 GetUserAttributes 或 DeleteUser 的任何下一个请求,我如何利用返回的用户令牌?我看到有userPool.getCurrentUser();,但这在 .Net SDK 中不可用,我认为它在 …
我尝试将currenturl分配给SiteName(全局变量),但在更改为新方法时,SiteName(全局变量)变为null.有人可以帮忙吗?
public string SiteName;
public ActionResult Admin()
{
string currentUrl = HttpContext.Request.Url.Segments.Last();
SiteName = currentUrl;
return View();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Ajax 请求中发布文件。它在本地主机中工作,但在服务器上发布后却没有,它总是返回 404。
不知道是不是路线问题。
如果有人能给我一些想法,我很感激。
我的代码在这里:
看法:
<form method="post" enctype="multipart/form-data">
<input type="file" id="files"
name="files" multiple />
<input type="button"
id="upload"
value="Upload Selected Files" />
Run Code Online (Sandbox Code Playgroud)
控制器:
[HttpPost]
public IActionResult UploadFilesAjax()
{
long size = 0;
var files = Request.Form.Files;
foreach (var file in files)
{
var filename = ContentDispositionHeaderValue
.Parse(file.ContentDisposition)
.FileName
.Trim('"');
filename = hostingEnv.WebRootPath + $@"\{filename}";
size += file.Length;
using (FileStream fs = System.IO.File.Create(filename))
{
file.CopyTo(fs);
fs.Flush();
}
}
string message = $"{files.Count} file(s) / {size} bytes uploaded successfully!";
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试将应用程序配置为使用我的类(派生自DbContext)ApplicationDbContext连接到我的数据库。我已经制作了配置文件appsetting.json:
"Data": {
"SportStoreProducts": {
"ConnectionStrings":"Server=(localdb)\\MSSQLLocalDB;Database=SportStore;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
Run Code Online (Sandbox Code Playgroud)
我使用依赖注入通过 Startup 构造传递对象实现IConfiguration(即appsetting.json):
public class Startup
{
public Startup(IConfiguration configuration) => Configuration = configuration;
public IConfiguration Configuration { get; }
}
Run Code Online (Sandbox Code Playgroud)
现在我想在ConfigureServices方法中使用这个配置文件Startup并使用扩展方法AddDbContext来注册我ApplicationDbContext使用SportStore我在配置文件中分配的SQL数据库():
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(
options => options.UseSqlServer(***);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我应该将什么UseSqlServer作为参数 (***)传递给方法,以便它可以使用我提供的配置属性将上下文连接到 SQL Server 数据库?
这是我的json:
[
{"ID":"1","DATETIME":"2018-05-02T00:00:00"},
{"ID":"2","DATETIME":"2018-05-02T00:00:00"},
{"ID":"3","DATETIME":""},
{"ID":"4","DATETIME":"2018-05-02T00:00:00"}
]
Run Code Online (Sandbox Code Playgroud)
我正在使用DataTable dt = JsonConvert.DeserializeObject<DataTable>(jsondata);从 json 转换为数据表,但是使用空日期时间列我收到以下错误:
字符串未被识别为有效的 DateTime。无法在 DATETIMEColumn 中存储 <>。预期类型为 DateTime。
那么如何将我的 json 转换为所有列都是字符串的数据表
我正在尝试Area在我的 ASP.Net MVC Core 2 应用程序中为管理员实现一个。
我已经为该区域配置了如下路由:
// Default route
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
// Admin area route
app.UseMvc(routes =>
{
routes.MapRoute(
name: "admin",
template: "{area=Admin}/{controller=Home}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
这一切都很好。
该管理员area使用与Layout主网站相同的内容,尽管它_ViewStart.cshtml位于Areas/Admin/Views目录中,但仍然可以正常工作。
我遇到的问题是位于主站点布局文件中的导航菜单组件以及href所有锚点中的链接在管理区域内指向错误的 URL。
假设我有以下链接:
<a asp-controller="Account" asp-action="Index">My Account</a>
<a asp-controller="Shopping" asp-action="Basket">Shopping Basket</a>
<a asp-controller="Admin" asp-action="Users">Manage Users</a>
Run Code Online (Sandbox Code Playgroud)
在管理区域内时,链接现在是相对于该区域的,因此看起来如下所示:
http://localhost/Admin/Account/Index
http://localhost/Admin/Shopping/Basket
http://localhost/Admin/Admin/Users
Run Code Online (Sandbox Code Playgroud)
有什么好的方法可以使所有这些链接都相对于站点根目录吗?
c# ×12
asp.net-mvc ×8
.net-core ×2
asp.net ×2
json ×2
ajax ×1
asp.net-core ×1
dbcontext ×1
getjson ×1
javascript ×1
jquery ×1
json.net ×1
razor ×1
rest ×1
routes ×1