Tag: asp.net

在C#中读取word文档

我想在服务器中读取word文档(doc和docx)。 服务器没有安装办公室,因此我不能使用com对象,也没有商业软件。 有没有办法可以单独使用办公工具并阅读docs这个词(2003年和2007年)

我想检测用户何时关闭浏览器窗口?

我有示例,我需要在用户关闭浏览器窗口时终止会话。 我试过page_unload()无法正常工作。 示例是:我有父窗口,窗口将从中打开我需要在用户关闭子窗口时删除会话。 拜托,我需要一些帮助。

ASP.NET发布到Facebook Wall

我试图发布到Facebook墙, 而不使用像C#Facebook SDK这样的API。 我正确地获取了访问令牌以及所有这些,但我使用以下代码禁止403: protected string postToWall() { var accessToken = Session[“_FB_ACCESS_TOKEN”]; var graphId = Session[“_FB_USER_GRAPH_ID”]; var url = string.Format( “https://graph.facebook.com/{0}/feed”, graphId ); var req = WebRequest.Create(url); req.Method = “POST”; req.ContentType = “application/x-www-form-urlencoded”; string postData = string.Format( @”curl -F ‘access_token={0}’ -F ‘message=This is a test…’ https://graph.facebook.com/{1}/feed”, accessToken, graphId ); byte[] byteArray = Encoding.UTF8.GetBytes(postData); var stream […]

如何使用后退按钮成功登录后阻止用户返回登录页面

我正在研究MVC3应用程序,并且遇到登录安全问题。 该场景是用户使用他/她的用户名和密码登录,如果正确,他/她将被重定向到他们的主页。 但如果他们点击浏览器后退按钮,他们会回到登录页面,在我的情况下,我不想要。 它与facebook,gmail等相同,一旦用户使用他/她的凭据登录,他们只需单击浏览器的后退按钮就无法返回登录页面。

使用对象列表填充UserControl Gridview

我有一个名为“Reasons”的对象列表,其中包含两个属性“Code”和“Text”。 我想用它来填充Gridview的UserControl。 但是,我不明白如何将gridview链接到原因列表,并实际设置从对象中使用哪些数据。 我假设方法是将数据源设置为List,但是,这不起作用,因为它似乎用任何行填充gridview。 有没有更好的方法来解决这个问题?

如何从javascript更改asp:textbox的值

我有一个asp:文本框 当用户点击“取消”按钮时,我想通过使值仅为“”来擦除该文本框中的任何内容。 如果它是类型文本的输入字段,我可以在javascript中执行此操作: document.getElementById(‘NewName’).value= “”; 但我不能这样做,因为它是一个asp:文本框。

在.net core 2.0中缓存声明

到处看,但看起来我现在被卡住了。 我在我的应用程序中使用Windows Active Directory进行身份validation。 对于授权,我正在使用索赔。 在搜索有限的.net核心文档后,这就是我的代码的样子。 Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddTransient( provider => provider.GetService().HttpContext.User); services.AddTransient(); services.AddAuthentication(IISDefaults.AuthenticationScheme); } ClaimsTransformer.cs class ClaimsTransformer : IClaimsTransformation { public Task TransformAsync(ClaimsPrincipal principal) { // call to database to get more claims based on user id ClaimsIdentity.Name ((ClaimsIdentity)principal.Identity).AddClaim(new Claim(“now”,DateTime.Now.ToString())); return Task.FromResult(principal); } } 但问题是,每次请求都会调用此代码,并且每次从db加载声明都是绝对错误的。 有什么方法可以缓存它吗? 我能够创建一个声明的cookie,并使用该cookie进行.net 4.0中的任何进一步调用。 我似乎无法找到核心方式。 我检查的任何文档都不完整,或者不包括我的场景。 […]

在扩展Roles表之后,实体类型IdentityRole不是当前上下文的模型的一部分

我扩展了由Entity Framework创建的AspNetRoles,如下所示: public class AspNetRoles:IdentityRole { public AspNetRoles() : base() { } public String Label { get; set; } public String ApplicationId { get; set; } public AspNetApplications Application { get; set; } public static readonly String SystemAdministrator = “SystemAdministrator”; } 我明白,因为我扩展了identityrole表,我不得不对我的用户管理员进行更改。 这就是我所做的: public class ApplicationUserManager : UserManager { public ApplicationUserManager(IUserStore store) : base(store) { […]

在C#.NET MVC应用程序中执行预定任务

我正在尝试为我的.NET MVC应用程序实现一个逻辑,我将在以下基础上触发我的应用程序中的计划任务: First scheduled task to run from 00 am to 1 am in the morning Second scheduled task to run from 1:10 am to 08:00 am in the morning Third scheduled task to run from 8:15 am to 11:15 pm every 1 hour 这将每年365天每天重复…… 我可以使用.NET或外部库中的哪种机制以最简单的方式实现这一点? 我试图用Quartz.NET库实现它,但我根本不喜欢它,我有两个计划的任务运行,其中一个在预定的时间内根本不会运行…

iPhone Web App缓存持久性

我如何编写一个ASP.NET(C#)应用程序,当它被标记为“主屏幕图标”时,该应用程序可以永久缓存在iPhone上? 我试过在“Response.ExpiresAbsolute = DateTime.MaxValue;”背后的代码上设置它。 但无济于事。 每次启动主屏幕图标时,仍会执行服务器代码。