-2

次のコードを取得しました。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);
}
%>

ブラウザで表示されるエラーは次のとおりです。

    Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1513: } expected

Source Error:


Line 1:  <%@ Page Language="C#" Debug="true" %>
Line 2:  <%
Line 3:  using System;
Line 4:  
Line 5:  protected string callRotate()

Source File: c:\inetpub\wwwroot\testing\testing.aspx    Line: 3 

更新 1: 今、私はこのエラーを取得しています:

Compiler Error Message: CS1519: Invalid token 'using' in class, struct, or interface member declaration

Source Error:


Line 1:  <%@ Page Language="C#" Debug="true" %>
Line 2:  <script runat="server">
Line 3:  using System;
Line 4:  
Line 5:  protected string callRotate()

更新 2:

エラー:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0246: The type or namespace name 'ProcessStartInfo' could not be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 5:  protected string callRotate()
Line 6:  {
Line 7:     ProcessStartInfo info = new ProcessStartInfo();
Line 8:     string[] arguments = { "arg1" , "arg2" };
Line 9:     info.FileName = "ConsoleApplication1";

Source File: c:\inetpub\wwwroot\testing\testing.aspx    Line: 7 

コードは次のとおりです。

<%@ 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>

更新 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>
4

1 に答える 1