Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET代码将不会运行,出现错误:找不到资源_C#_Asp.net - Fatal编程技术网

C# ASP.NET代码将不会运行,出现错误:找不到资源

C# ASP.NET代码将不会运行,出现错误:找不到资源,c#,asp.net,C#,Asp.net,我已经得到了以下代码,我希望只需在我的浏览器中加载使用IIS 7运行的页面 <%@ Page Language="C#" Debug="true" %> <% using System; protected string callRotate() { ProcessStartInfo info = new ProcessStartInfo(); string[] arguments = { "arg1" , "arg2" }; info.FileNam

我已经得到了以下代码,我希望只需在我的浏览器中加载使用IIS 7运行的页面

<%@ Page Language="C#" Debug="true" %>
<%
using System;

protected string callRotate()
{
    ProcessStartInfo info = new ProcessStartInfo();
    string[] arguments = { "arg1" , "arg2" };
    info.FileName = "ConsoleApplication1";

    Process process = Process.Start(info.FileName, arguments);
    Process.Start(info);
}
%>
代码如下:

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<script runat="server">

protected string callRotate()
{
    ProcessStartInfo info = new ProcessStartInfo();
    string[] arguments = { "arg1" , "arg2" };
    info.FileName = "ConsoleApplication1";

    Process process = Process.Start(info.FileName, arguments);
    Process.Start(info);
}
</script>

受保护的字符串callRotate()
{
ProcessStartInfo=newProcessStartInfo();
字符串[]参数={“arg1”,“arg2”};
info.FileName=“ConsoleApplication1”;
Process=Process.Start(info.FileName,参数);
进程启动(信息);
}
更新3: 啊,好的,之前我切换到使用命令行应用程序,因为我无法让这些代码在浏览器中工作,但现在您已经向我展示了如何切换回在浏览器中运行它

所以我把我的应用程序转换成浏览器,一切都很好。但是如何获取url变量呢

我知道这与Request.QueryString有关,但这不起作用,我添加了以下行:

当前代码:

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Web" %>

<script runat="server">
static void Main(string[] args)
{
    string url = Request.QueryString["url"];
    string rotate_dir = Request.QueryString["dir"];

    //create an image object from the image in that path
    System.Drawing.Image img = System.Drawing.Image.FromFile(url);

    //Rotate the image in memory
    if (direction == "clockwise")
    {
        //Rotate clockwise
        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
    } else if (direction == "anticlockwise") 
    {
        //Rotate anti-clockwise
        img.RotateFlip(RotateFlipType.Rotate90FlipXY);
    }

    //Delete the file so the new image can be saved
    System.IO.File.Delete(url);

    //save the image to the file
    img.Save(url);

    //release image file
    img.Dispose();
}
</script>

静态void Main(字符串[]参数)
{
字符串url=Request.QueryString[“url”];
字符串rotate_dir=Request.QueryString[“dir”];
//从该路径中的图像创建图像对象
System.Drawing.Image img=System.Drawing.Image.FromFile(url);
//在内存中旋转图像
如果(方向=“顺时针”)
{
//顺时针旋转
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
}否则,如果(方向=“逆时针”)
{
//逆时针旋转
img.RotateFlip(RotateFlipType.Rotate90FlipXY);
}
//删除文件以便保存新图像
System.IO.File.Delete(url);
//将图像保存到文件中
img.Save(url);
//发布图像文件
img.Dispose();
}

由于您在发布的代码中没有显示实际的页面名称,我假设
tesing.aspx
应该是
testing.aspx
,请将您的URL更改为:

/testing/testing.aspx 
更新1:


您正试图通过
使用内嵌的代码块您站点的文件夹结构是什么?您是否检查
tesing.aspx
拼写是否正确?是否有理由不使用单独的代码隐藏文件?有一个与页面相关的C#代码文件可能更有意义,而不是将所有内容都放在标记中。这是一个非常令人困惑的问题,因为您的更新显示了您的新结果,而实际上似乎没有说明是什么更改导致了这些新错误……错误与“使用系统”正如您在我更新的帖子中所看到的。您不能在嵌入式代码块中使用
语句,您必须使用
@Import
页面指令,请参阅更新的答案。很抱歉,我已经有一段时间没有使用嵌入式代码块了,因此我很抱歉之前没有提到这一点。正如您所知,该文件保存为如下
http://localhost/testing/testing.aspx
我现在收到此错误:
编译器错误消息:CS0246:找不到类型或命名空间名称“Import”(您是否缺少using指令或程序集引用?
请参阅我的答案中的更新3。似乎还有一个问题。
编译器错误消息:CS1502:System.Diagnostics.Process.Start(string,string)”的最佳重载方法匹配有一些无效参数
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<script runat="server">

protected string callRotate()
{
    ProcessStartInfo info = new ProcessStartInfo();
    string[] arguments = { "arg1" , "arg2" };
    info.FileName = "ConsoleApplication1";

    Process process = Process.Start(info.FileName, arguments);
    Process.Start(info);
}
</script>
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Web" %>

<script runat="server">
static void Main(string[] args)
{
    string url = Request.QueryString["url"];
    string rotate_dir = Request.QueryString["dir"];

    //create an image object from the image in that path
    System.Drawing.Image img = System.Drawing.Image.FromFile(url);

    //Rotate the image in memory
    if (direction == "clockwise")
    {
        //Rotate clockwise
        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
    } else if (direction == "anticlockwise") 
    {
        //Rotate anti-clockwise
        img.RotateFlip(RotateFlipType.Rotate90FlipXY);
    }

    //Delete the file so the new image can be saved
    System.IO.File.Delete(url);

    //save the image to the file
    img.Save(url);

    //release image file
    img.Dispose();
}
</script>
/testing/testing.aspx 
<script runat="server">
    using System; 

    protected string callRotate()
    ... Rest of your code here
</script>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Diagnostics" %>
Process execute = new Process();
execute.StartInfo.FileName = "ConsoleApplication1";
execute.StartInfo.Arguments = @"-log d:file.txt -c ""arg2"" -y ""arg3"" -z ""HOW?""";
execute.Start()
protected void Page_Load(object sender, EventArgs e)
{
    string url = Request.QueryString["url"];
    string rotate_dir = Request.QueryString["dir"];
}