前几天我在堆栈溢出的一些精彩帮助之后整理了一个下载脚本.但是我现在发现在下载文件之后我需要重新加载页面以摆脱aspx页面上的进度模板.在我添加下载代码之前,删除模板的代码工作正常.
删除进度模板的代码: upFinanceMasterScreen.Update();
我试过在重定向到之前和之后调用它 IHttpHandler
Response.Redirect("Download.ashx?ReportName=" + "RequestingTPNLeagueTable.pdf");
public class Download : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
StringBuilder sbSavePath = new StringBuilder();
sbSavePath.Append(DateTime.Now.Day);
sbSavePath.Append("-");
sbSavePath.Append(DateTime.Now.Month);
sbSavePath.Append("-");
sbSavePath.Append(DateTime.Now.Year);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpResponse objResponce = context.Response;
String test = HttpContext.Current.Request.QueryString["ReportName"];
HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + test);
objResponce.WriteFile(context.Server.MapPath(@"Reports\" + sbSavePath + @"\" + test));
}
public bool IsReusable { get { return true; } }
Run Code Online (Sandbox Code Playgroud)
感谢您的任何帮助,您可以提供!
在我的jsp中,如果我打电话<form action="/sampleServlet" method="get" name="form1">,我得到以下异常:
http 404错误 - 找不到sampleServlet.我在web.xml文件中设置sampleServlet,url-pattern也设置为/ sampleServlet.
为什么我得到404(找不到servlet.)?
我有一个包含EquipmentID列表的表和另一个包含维护记录的表.
当用户编辑维护记录时,我希望有一个表格中所有设备ID的下拉列表.
下拉列表会填充,并填充正确数量的条目,但是它们都会说System.Web.MVC.SelectListItem而不是ID的值.
以下是生成列表的代码:
public ActionResult Edit(int id)
{
MaintPerformed maintPerformed = maintPerformedRepository.GetMaintPerformed(id);
IList<EquipmentID> IDs = equipmentIDRepository.GetEquipmentIDAsList();
IEnumerable<SelectListItem> selectEquipList =
from c in IDs
select new SelectListItem
{
//Selected = (c.EquipID == maintPerformed.EquipID),
Text = c.EquipID,
Value = c.Sort.ToString()
};
ViewData["EquipIDs"] = new SelectList(selectEquipList, maintPerformed.ID);
return View(maintPerformed);
}
Run Code Online (Sandbox Code Playgroud)
以下是下拉列表的.aspx页面中的条目:
%: Html.DropDownList("EquipIDs") %>
Run Code Online (Sandbox Code Playgroud)
以下是我从表中生成列表的方法:
public List<EquipmentID> GetEquipmentIDAsList()
{
return db.EquipmentIDs.ToList();
}
Run Code Online (Sandbox Code Playgroud)
除了分配要在下拉框中显示的文本外,一切都正常工作.
我错过了什么或没有正确思考?
我们在使用.NET Remoting时遇到了一个奇怪的问题.基本上,我们有一个服务器,它注册两个TcpChannels ChannelServices.RegisterChannel():
然后我们有一个客户端注册一个TcpChannel,以便能够与服务器通信.我们通过Activator.GetObject()使用URI 调用从服务器检索一个对象
"TCP:// SERVERIP:50000 /对象名"
这工作正常,客户端连接到端口50000上的服务器并获取对象.
但是,当我们开始调用该对象上的方法时,将丢弃与端口50000上的通道的连接,并自动在端口15000上建立与该通道的新连接.这对我们来说是一个真正的问题,因为我们不希望端口15000上的流量,因为该通道可能没有绑定到与服务器上的端口50000通道相同的网络适配器,或者该端口可能未在防火墙中打开,这会导致远程召唤自然失败.
这对我们来说非常奇怪,因为客户端在我们的代码中不知道端口15000上的服务器上存在另一个通道或它侦听的IP,但它尝试连接到它.
非常感谢任何帮助,
谢谢,卡斯帕
这是设置其中一个服务器通道的代码,通常在端口50000上:
IDictionary props = new Hashtable();
props["port"] = m_tcpPort;
props["name"] = String.Empty;
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
m_tcpChannel = new TcpServerChannel( props, /*clientProvider,*/ serverProvider );
ChannelServices.RegisterChannel( m_tcpChannel, false );
m_wellKnownObjRef = RemotingServices.Marshal( this, "Server@" + m_tcpPort.ToString() );
Run Code Online (Sandbox Code Playgroud)
这是设置其他服务器通道的代码,通常在端口15000上:
IDictionary props = new Hashtable();
props["name"] = String.Empty;
props["port"] = ip.Port;
props["bindTo"] = ip.Address.ToString();
props["timeout"] = …Run Code Online (Sandbox Code Playgroud) 先生,我在java应用程序中工作.在该应用程序中,我必须从"我的文档"访问文件.当我使用Windows 7时,问题出现在windows版本中,它可以作为"Documents"文件夹访问,但对于Windows XP,它是"我的文档".
我正在编写以下代码来访问Windows 7中"Documents"文件夹中的文件.
public static void main(String[] arr)
{
try
{
String source = System.getProperty("user.home")+ File.separator + "Documents";
File[] Files = new File(source).listFiles();
System.out.println(Files.length);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
适用于Windows XP
public static void main(String[] arr)
{
try
{
String source = System.getProperty("user.home")+ File.separator + "My Documents";
File[] Files = new File(source).listFiles();
System.out.println(Files.length);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
请问您能否建议一种通用方法,可以应用于所有版本的Windows?
我有一个表人士及地址.一个人可以拥有多个地址记录,因此与Address的简单1 ..*关系具有引用"人员ID"的字段.
现在,对于给定的人,我希望识别他们的"默认"或"主要" 地址.
我想出了两个想法,但我也不相信.在我决定之前,任何人都可以提出任何关于潜在问题的评论我可以面对任何一个选项...
(一个).可以在Person上有一个"默认地址ID" ,它将存储默认地址记录的ID .这里可能存在的缺陷是可以在此处设置不属于此Person的地址,因此需要额外的检查约束来防止这种情况.
(b)中.可以在地址表上有一个"默认"标志,但这有可能允许多个选择,因此需要进一步检查,以便在设置标志时,它也会在属于同一个人的所有记录上清除.
任何
我有一个使用Timer的类.这个类实现IDispose.我想在Dispose方法中等待,直到计时器不会再次触发.
我这样实现它:
private void TimerElapsed(object state)
{
// do not execute the callback if one callback is still executing
if (Interlocked.Exchange(ref _timerIsExecuting, 1) == 1)
return;
try
{
_callback();
}
finally
{
Interlocked.Exchange(ref _timerIsExecuting, 0);
}
}
public void Dispose()
{
if (Interlocked.Exchange(ref _isDisposing, 1) == 1)
return;
_timer.Dispose();
// wait until the callback is not executing anymore, if it was
while (_timerIsExecuting == 0)
{ }
_callback = null;
}
Run Code Online (Sandbox Code Playgroud)
这个实现是否正确?我认为这主要取决于_ timerIsExecuting == 0是一个原子操作的问题.或者我必须使用 …
我正在使用C#,并且无法理解如何从子进程异步读取stdout.我想要做的是创建一个子进程来执行一个应用程序,然后在文本框中显示从该进程'stdout收到的任何内容.我需要立即查看子进程中的每个输出字符,并且不能等待一行完成,因此我认为该Process.OutputDataReceived事件不符合我的目的.你能告诉我一个理智的方法吗?
我已经尝试调用Process.StandardOutput.BaseStream.BeginRead()并向其传递回调函数,但在此回调函数中,我收到了一个异常Process.StandardOutput.BaseStream.EndRead().
我的代码看起来像这样(子进程是一个脚本引擎 - 缩写为"SE" - 用于验证外部设备的功能.脚本按顺序执行,每个脚本需要一个SE应用程序实例)
private bool startScript()
{
// Starts the currently indexed script
if (null != scriptList)
{
if (0 == scriptList.Count || scriptListIndexer == scriptList.Count)
{
// If indexer equals list count then there are no active scripts in
// the list or the last active script in the list has just finished
return false; // ## RETURN ##
}
if (ScriptExecutionState.RUNNING == scriptList[scriptListIndexer].executionState)
{
return false; …Run Code Online (Sandbox Code Playgroud) 当用户尝试通过链接访问我们的网站时(例如访问www.website.com/privatepage),他们会被重定向到登录页面.登录后,我们希望将它们重定向到预期的网址 - 您是如何做到这一点的?
此外,我们还有一个用例,用户从主页登录,或者直接进入没有预期URL的登录页面 - 在这种情况下,我们想将它们重定向到默认页面.
任何人都可以帮我解决这个问题吗?
我编写了一个从文本文件中读取的程序,可以创建它们来加载和保存数据.我有一些文件是程序启动时加载的"默认"数据.这些文件由静态引用加载.我的代码在发布之前运行正常,但很明显,当我发布它时,静态引用不再有效.我不知道如何将默认数据添加到构建中作为不同的文本文件,以便我仍然可以在构建后引用它.
我想能够构建程序并拥有一些随可执行文件一起提供的文件夹,其中包含我可以轻松引用的默认数据文件,但我不知道该怎么做(或者如果有更好的方法) .
下面是我用来从文件中读取的代码的开头.目前,默认数据的文件名是静态传递到sub中的,用于标识要读取的文件,所以我想要一个我可以做同样事情的已发布文件.
Try
Dim sr As New IO.StreamReader(FileName)
Dim strLine As String = ""
Do Until sr.EndOfStream
strLine = sr.ReadLine
'Code that interprets the data in the file
Run Code Online (Sandbox Code Playgroud)
注意:我尝试将文件添加为"资源",但我似乎无法将该文件作为文本文件引用; 我只能检索文档中包含的大量文本墙,这些文本不能与上面的代码一起使用(除非我当然缺少某些内容).
如果你能澄清一下: