var docprint = window.open("", "", "toolbar=0,location=0,menubar=0,scrollbars=1");
docprint.document.open();
docprint.document.write("<html><head><title>Title here</title></head>");
docprint.document.write("<body>body content here</body></html>");
docprint.document.close();
docprint.focus();
docprint.print();
Run Code Online (Sandbox Code Playgroud)
这是我的javascript代码,用于打开一个新窗口并自动打开打印对话框.当用户从打印对话框中选择要打印到Adobe PDF的选项时,会出现一个菜单,其中包含用于定义pdf文件名的选项.在Firefox和Chrome中,pdf文件名设置为页面标题,这很好.但是,在Internet Explorer中,pdf文件名设置为父窗口的url basename.如何在Internet Explorer中以编程方式设置pdf文件名?
我有一个有效的未过期代码签名证书(标准,不是 EV),我曾用它来成功签署一次单击应用程序 (.net 4.5) 并发布到 Web 服务器以供下载。下载此应用程序时,它会正确显示发布者名称。问题是,在任何其他应用程序上安装代码签名证书后,它在下载时将发布者名称显示为“未知发布者”。我安装证书的方式和所有应用程序都发布到同一 Web 服务器的方式没有任何区别。当我登录到 Web 服务器时打开 .exe 或清单文件时,它会正确显示发布者名称。检查“数字签名”文件属性表明它们是使用正确的代码签名证书和 sha256 签名的。以下是我使用的步骤:
附带说明一下,我使用 SHA1 从 Internet Explorer 导出代码签名证书,然后将其安装到 Web 服务器。存在一个已知问题,即当证书已导出为 SHA256 并尝试将其导入 Web 服务器时,文件的密码将始终显示不正确。这发生在我身上,所以我只是将 SHA1 版本导入到 Web 服务器。不确定这是否会产生任何问题,但它适用于一键式应用程序。
更新:如果我转到发布部署 URL 并单击“安装”按钮,我会注意到一些奇怪的东西。在为带有“未知发布者”的 clickonce 应用程序下载 setup.exe 后,我看到一个更可怕的智能屏幕过滤器,说该文件未签名,但在其下方显示正确的发布者信息。检查 exe 的“数字签名”属性表明它已正确签名。
我下面的代码使用 C# 和 HTMLAgilityPack 抓取网页,然后使用 WebClient 从另一个网页下载字符串。这在 localhost 上效果很好,但是当我在 Azure 上将代码发布为 API 服务或在 Web 托管服务(即主机 gator)上执行时,我总是收到 403 禁止错误。我已经尝试了很多方法来让它发挥作用,但我一生都无法弄清楚这一点。任何帮助将不胜感激。
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load("https://antenati.cultura.gov.it/ark:/12657/an_ud18290200");
//string returnedResult = doc.DocumentNode.OuterHtml; //this shows a 403 forbidden error response when not running from localhost.
string ress = doc.DocumentNode.SelectSingleNode("//*[text()[contains(., 'manifestId:')]]").InnerText;
if (!string.IsNullOrEmpty(ress))
{
string[] strPieces = ress.Split(new string[] { "manifestId:" }, StringSplitOptions.None);
if (strPieces.Length >= 2)
{
WebClient wb = new WebClient();
string manifestUrl = strPieces[1].Split(',')[0].Replace("'", "").Trim();
wb.Headers.Add("origin", "https://antenati.cultura.gov.it");
wb.Headers.Add("referer", "https://antenati.cultura.gov.it/");
wb.Headers.Add("user-agent", …Run Code Online (Sandbox Code Playgroud) c# localhost web-scraping http-status-code-403 html-agility-pack
我有一个使用模型视图对象的表单,该对象在提交表单的回发时不更新文本框值.在提交表单时,我编辑绑定到文本框的对象的属性.表单返回时,对象属性仍然更改,但文本框值不会更改.这就像文本框值被缓存一样,不会改变.我该如何解决?
文本框默认值:""
文本框代码:
@Html.TextBoxFor(m => m.Project.tNumber, new { @readonly = "readonly", @class = "readonly" })
Run Code Online (Sandbox Code Playgroud)
对象属性:
[Display(Name = "T Number")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string tNumber { get; set; }
Run Code Online (Sandbox Code Playgroud)
控制器动作方法:
[Authorize(Roles = "Admin, OrderEntryManager")]
[HttpPost]
public ActionResult Verify(string submit, OrderEntryEdit model)
{
MembershipUser user = Membership.GetUser(User.Identity.Name);
int userId = WebSecurity.GetUserId(User.Identity.Name);
if (userId > 0)
{
if (ModelState.IsValid)
{
string ButtCommand = submit;
switch (ButtCommand)
{
case "Create Order":
if (model.CreateOrder(userId))
{
ViewBag.Status = "success";
ViewBag.Message = "The order has …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×1
c# ×1
certificate ×1
clickonce ×1
filenames ×1
iis-8 ×1
javascript ×1
localhost ×1
model-view ×1
pdf ×1
printing ×1
publisher ×1
textbox ×1
web-scraping ×1