使用 Process.StartInfo.UserName
我的网站有一个可打开游戏的链接按钮:
Process game= new Process();
game.StartInfo.FileName = HttpContext.Current.Request.MapPath("~/iFarkle.exe");
game.StartInfo.UserName = Session["Username"].ToString();
game.StartInfo.UseShellExecute = false;
game.Start();
如何使用 StartInfo.UserName? (现在不起作用,我输入了错误的数据,它仍然存在)(无需 StartInfo.UserName 即可工作
I have a website that has a linkbutton that opens a game :
Process game= new Process();
game.StartInfo.FileName = HttpContext.Current.Request.MapPath("~/iFarkle.exe");
game.StartInfo.UserName = Session["Username"].ToString();
game.StartInfo.UseShellExecute = false;
game.Start();
How do I use the StartInfo.UserName?
(it doesn't work right now, it stays I entered bad data)(works without the StartInfo.UserName
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望 exe 在用户计算机上运行,您可以:
提供 exe 文件的直接链接(并确保您的服务器配置为提供 .exe 文件),或者,
将文件内容流回响应(确保设置响应 ContentType 到合适的类型(我认为 application/x-msdownload 可以))。
例如,如果我打算在允许下载之前执行一些额外的检查,我只会执行第二个操作。当然,一旦用户下载了 exe,他们就可以随意使用它。
另请注意,只有当 exe 没有它所依赖的任何其他 DLL 时,这才有效(可以安全地假设已经可以在客户端计算机上访问的 DLL 除外)。
If you want the exe to run on the users computer, you can either:
Provide a direct link to the exe file (and make sure your server is configured to serve .exe files), or,
Stream the contents of the file back in the response (having made sure to set the Response ContentType to a suitable type (I think application/x-msdownload would work)).
I'd only do the second if I was going to, for example, perform some additional checks before allowing the download. Of course, as soon as the user has downloaded the exe, they'll be free to do with it whatever they please.
Also note that this will only work if the exe doesn't have any other DLLs it relies on (except DLLs which are safe to assume will already be accessible on the client machine).