使用托管的asp.net应用程序在客户端计算机上创建快捷方式 [英] Create Shortcut on Client machine using hosted asp.net application

查看:110
本文介绍了使用托管的asp.net应用程序在客户端计算机上创建快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我比较新鲜,已经创建了一个Web应用程序并将其托管在IIS上,现在我想在客户端计算机桌面上创建快捷方式,当用户单击快捷方式时它将包含该URL的URL.因此我尝试了以下代码来执行此操作,并且该代码可以在我的计算机上运行,​​但是当我尝试从IIS执行该操作时却不起作用.
所以有人可以帮我吗.在客户端计算机上创建快捷方式

Hi..
I am a fresher and have created a web application and hosted it on IIS, now i want to create shortcut on client machines desktop which will contains url when user clicks shortcut it will go to that url. so i have tried Following code to do so and it is working on my machine but when i am try to execute from IIS it did not works.
So can some one please help me. To create Short cut on Client machine

protected void LinkButton1_Click(object sender, EventArgs e)
{
HttpBrowserCapabilities bc = Request.Browser;

string browserName = bc.Browser;
dynamic wsh = Microsoft.VisualBasic.Interaction.CreateObject("WScript.Shell");

wsh = Microsoft.VisualBasic.Interaction.CreateObject("WScript.Shell");

dynamic MyShortcut = null;

dynamic DesktopPath = null;

DesktopPath = wsh.SpecialFolders("Desktop");

MyShortcut = wsh.CreateShortcut(DesktopPath + "\\MyShortcut1.lnk");

MyShortcut.Arguments = "www.yahoo.com";

MyShortcut.Save();
}

推荐答案

Web应用程序在Web浏览器中运行,并且不允许访问浏览器外部的任何用户系统资源.因此,Web应用程序无法在用户的桌面上创建快捷方式.您需要指导用户创建桌面快捷方式.如果他愿意,那么他将创建快捷方式,否则不创建.

您编写的代码在服务器(或本地主机)上执行,并在其中创建快捷方式.但是对于用户而言,代码将在远程计算机上执行,而不是在其计算机上执行,以创建快捷方式.了解客户端-服务器体系结构.它根本不可能.

您是否在其他任何网站上看到过任何此类功能?
A web application runs inside the web browser and is not allowed to access any of the user''s system resources outside the browser. So a web app cannot create a shortcut on user''s desktop. You need to instruct the user to create the shortcut to his desktop. If he wants then he will create the shortcut otherwise not.

The code you have written executes on the server ( or your localhost) and creates the short cut there. But for a user, the code executes on the remote machine and NOT on his machine for the short cut to be created. Understand the client-server architecture. Its simply NOT possible.

Have you seen any such functionality on any other website ?


这是无法完成的,这是有原因的–网站无法(也永远不会)访问浏览器之外的客户端计算机.

如果用户使用Windows,只需告诉用户将链接或URL拖到桌面上即可.
This can''t be done, and for good reason – websites don''t (and never should) have access to the client machine outside the browser.

Simply tell your users to drag a link or URL onto the desktop, if they''re using Windows.


这篇关于使用托管的asp.net应用程序在客户端计算机上创建快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆