我有一个在运行时生成的动态链接的动态列表,如下所示:
@Html.ActionLink(x.Name, "Index", "User", new { x.ID }, null)
Run Code Online (Sandbox Code Playgroud)
所以我在用户控制器上点击Index方法.
我也有我的RouteConfig.cs(它是一个MVC4应用程序)设置如下:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "",
url: "{controller}/{action}/{id}",
defaults: new { controller = "User", action = "Index", id = UrlParameter.Optional }
);
}
Run Code Online (Sandbox Code Playgroud)
这给了我链接server/application/User/Index/1列表中的链接.
在列表生成和/或路由文件中我需要做什么才能将其更改为server/application/User/1?
c# asp.net-mvc optional-parameters asp.net-mvc-routing asp.net-mvc-4
我只想在用户关闭我的 ASP.NET Web 窗体页面或离开它时向用户显示一条消息。如果他们单击任何 Button、LinkButton、AutoPostBack 元素或任何其他将回发的元素,那么我不想显示该消息。
到目前为止,我有以下代码:
<script type="text/javascript">
var postback = false;
addToPostBack = function(func) {
var old__doPostBack = __doPostBack;
if (typeof __doPostBack != "function") {
__doPostBack = func;
} else {
__doPostBack = function(t, a) {
if (func(t, a)) old__doPostBack(t, a);
}
}
};
$(document).ready(function() {
addToPostBack(function(t,a) {
postback = true;
});
});
$(window).bind("beforeunload", function() {
if (!postback) {
return "message";
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
这部分有效,但似乎阻止了 AutoPostBack 事件的触发,并且仍然显示 LinkButtons 等的消息。
我怎样才能做到这一点?
我的一些表格单元格中包含大量内容.我不想显示所有这些,直到用户在单元格上悬停,但我想在角落放一个箭头表示它可以悬停 - 就像在excel评论中一样.我怎么能用CSS做到这一点?

在ASP MVC5 RC我没有让角色系统工作.我的数据库有所有需要的表存在一个角色,但校对用户是否在角色中总是返回false(没有SQL异常或其他东西)!
我需要在IPrincipal某个地方激活角色系统吗?
测试代码:
AccountController accCont = new AccountController();
// check role exist : result = true
var roleExist = await accCont.IdentityManager.Roles.RoleExistsAsync("61c84919-72e2-4114-9520-83a3e5f09de1");
// try find role by name : result = role object
var role = await accCont.IdentityManager.Roles.FindRoleByNameAsync("ProjectAdministrator");
// check with AccountController instance : result = true
var exist = await accCont.IdentityManager.Roles.IsUserInRoleAsync(User.Identity.GetUserId(), role.Id);
// check if current user is in role : result (both) = false????
var inRole = User.IsInRole(role.Id);
var inRole2 = User.IsInRole(role.Name);
Run Code Online (Sandbox Code Playgroud)
我还尝试构建一个自定义的IIdentity.GetUserId()扩展,如 …
我正在努力处理ngx-monaco-editor一个primeng 选项卡面板内部的实例,该实例在切换到另一个选项卡时似乎会丢失其大小计算,更改绑定到编辑器的模型值,然后再次切换回初始选项卡。
https://stackblitz.com/edit/primeng9-tabs-monaco-editor
使用上述 URL 进行复制的步骤:
前:
后:
在 Dom 中检查,最初指定的样式仍然存在。
正如您从示例应用程序的源代码中看到的那样,我还尝试layout在选项卡更改事件中使用编辑器的方法来尝试根据容器强制重新计算大小,但这没有任何区别
有趣的是,如果我调整窗口大小,这似乎会触发编辑器组件再次正确调整大小。
我有以下代码
int intTimeout = (FormsAuthentication.Timeout.Hours * 60) +
FormsAuthentication.Timeout.Minutes;
var authTicket = new FormsAuthenticationTicket(1, Utility.userCookie, DateTime.Now,
DateTime.Now.AddMinutes(intTimeout), true, cookieValue);
string strEncryptedTicket = HttpUtility.UrlEncode(FormsAuthentication.Encrypt(authTicket));
var authCookie = new HttpCookie(Utility.userCookie, strEncryptedTicket);
authCookie.Expires = authTicket.Expiration;
//FormsAuthentication.RedirectFromLoginPage("", false);
authCookie.Secure = FormsAuthentication.RequireSSL;
//authCookie.Secure = true;
HttpContext.Current.Response.Cookies[Utility.userCookie].Expires = authTicket.Expiration;
HttpContext.Current.Response.Cookies[Utility.userCookie].Value = authCookie.Value;
Run Code Online (Sandbox Code Playgroud)
在web.config下面
<authentication mode="Forms">
<forms timeout="2" slidingExpiration="true" requireSSL="true" />
</authentication>
Run Code Online (Sandbox Code Playgroud)
我一直打到页面链接,它仍然会在2分钟后到期.
c# cookies asp.net-mvc form-authentication slidingexpiration
我担心Clients.All在我的C#Signal R集线器类中使用
Clients.All.setConnectionStatus(profileId, true);
Run Code Online (Sandbox Code Playgroud)
我在两者中调用它OnConnected()并OnDisconnected(bool stopCalled)
显示我登录用户的在线状态.
OnDisconnected()并不是那么糟糕,因为只有在有人实际注销时才会被调用
恩.
public override Task OnConnected()
{
string profileId = Context.User.Identity.Name;
_connections.Add(profileId, Context.ConnectionId);
Clients.All.setConnectionStatus(profileId, true);
return base.OnConnected();
}
public override Task OnDisconnected(bool stopCalled)
{
string profileId = Context.User.Identity.Name;
_connections.Remove(profileId, Context.ConnectionId);
if (stopCalled == false) // log off only
Clients.All.setConnectionStatus(profileId, false);
return base.OnDisconnected(stopCalled);
}
Run Code Online (Sandbox Code Playgroud)
我担心 - >用浏览器中不断运行的javascript代码炸毁用户机器客户端!
场景 - >如果我有~~ 1000个在线用户并登录到不同的页面,我将向他们所有人发送信号R连接 Clients.All.setConnectionStatus(profileId, true);
在javascript集线器中看起来像下面这可能很容易最终炸毁用户浏览器,因为它将不断接收这些广播连接状态调用!
scope.chat = $.connection.chatHub;
// Receive and set the connection status
scope.chat.client.setConnectionStatus = function(profileId, isConnected) …Run Code Online (Sandbox Code Playgroud)我有一个应用程序,当用户登录时,他收到了一些数据作为响应,但如果响应不是我所期望的,应用程序就会崩溃。
让我向您展示以下内容:
我创建了一个接口来告诉 Typescript 我期望的数据。
export interface AuthResponseData {
token: string;
expires: string;
role: number;
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个方法来将登录数据发送到服务器。
login(user: string, password: string){
return this.http.post<AuthResponseData>(
'https://localhost:44344/api/auth', { user: user, pwd: password }
).pipe(
catchError(this.handleError),
tap(resData => { this.handleAuthentication(resData.token, resData.expires, resData.role)})
);
}
Run Code Online (Sandbox Code Playgroud)
我期待如果来自服务器的响应与接口不匹配,那么 Angular 将重定向到catchError. 但不会发生。
现在我的问题是:有什么方法可以检查 API 响应是否等于接口,如果不是则抛出错误。或者我问的是不可能的?
更新:
搜索后,我发现接口在运行时消失了,因此无法将 api 响应与接口进行比较(据我所知)。但我一直在寻找一种以动态方式检查 api 响应的方法。我认为取决于 api 响应总是正确的,这并不是真正安全的。所以我应该检查 API 响应。我怎样才能做到这一点?
希望你能帮助我,谢谢:)
当我尝试在远程数据库上执行SQLQuery(由Update-Database -Verbose -f -ScriptVisual Studio中的本地生成)时,我看到SQL Server Management Studio返回以下错误:
Msg 2714,Level 16,State 6,Line 1
数据库中已经有一个名为"__MigrationHistory"的对象.
怎么解决这个?
我在网页中有一个 SVG,它由图像 + 文本组成
<object data="/infographic/timeline.svg" type="image/svg+xml">
<img src="/infographic/timeline.svg" alt="Timeline">
</object>
Run Code Online (Sandbox Code Playgroud)
所有的图像都是响应式的,但文本不是,所以文本变得非常非常小。
SVG 片段(大量的)
<defs>
<style>
.cls-1 {
font-size: 60.014px;
}
.cls-1, .cls-10 {
opacity: 0.69;
}
.cls-1, .cls-10, .cls-4, .cls-5, .cls-7, .cls-8, .cls-9 {
fill: #ffffff;
}
.cls-1, .cls-10, .cls-3, .cls-4, .cls-5, .cls-6, .cls-7, .cls-9 {
text-anchor: middle;
}
.cls-1, .cls-3, .cls-6 {
font-family: "Roboto";
}
.cls-2 {
font-size: 32.014px;
}
.cls-3 {
font-size: 14.089px;
}
.cls-3, .cls-6 {
fill: #db7426;
}
.cls-4, .cls-6 {
font-size: 32px!important;
}
.cls-10, …Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net-mvc ×3
angular ×2
asp.net ×2
javascript ×2
angular8 ×1
cookies ×1
css ×1
html-table ×1
jquery ×1
nuget ×1
primeng ×1
signalr ×1
signalr-hub ×1
svg ×1
typescript ×1