當請求來自調度程序時,無法寫入 App_Data (Cannot write in App_Data when request is from scheduler)


問題描述

當請求來自調度程序時,無法寫入 App_Data (Cannot write in App_Data when request is from scheduler)

Hello I have a page in an ASP.NET (website) project that writes a file to the App_Data folder. When I request the page from my browser everything works. When I perform this request from a cron-job scheduled job from my provider I get the following error

Could not find a part of the path 'C:\xxxxxxxxxxxxxxx\App_Data\Art_P00004.txt'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamWriter..ctor(String path, Boolean append)
   at System.IO.File.CreateText(String path)
   at AanbiedingProcessor.DoWriteFiles()
   at TskSendAanbiedingen.DoWork()

Can anyone help me ?

The cron jon runs on another host/domain as the asp.net website. I assume it just makes a web request.


參考解法

方法 1:

This is likely to be a permissions issue.

Ensure the user account associated with the scheduled job has access to the App_Data folder.

Process Monitor can help to check exactly what is failing and why.

方法 2:

The problem was that the path did not exist.. :(  The script called from the scheduler was different from the script (location) called within the browser. Excuse me for the confusion..

(by Julian de WitRichardJulian de Wit)

參考文件

  1. Cannot write in App_Data when request is from scheduler (CC BY-SA 3.0/4.0)

#Security #ASP.NET






相關問題

只允許 oracle db 登錄到特定的應用程序? (Allowing oracle db login only to specific application?)

在桌面應用程序中保存用戶名和密碼 (Saving username & password in desktop app)

如何使用算法 RSA/ECB/PKCS1Padding 通過 JavaScript 解密加密字符串 (How to decrypt through JavaScript of encrypted string using algorithm RSA/ECB/PKCS1Padding)

wcf:將用戶名添加到消息頭是否安全? (wcf: adding username to the message header is this secure?)

沒有 .htaccess 的安全目錄密碼保護 (Secure directory password protection without .htaccess)

無法在 Oracle 表上創建簡單視圖 (Unable to create a simple view on Oracle table)

當請求來自調度程序時,無法寫入 App_Data (Cannot write in App_Data when request is from scheduler)

安全的 PHP 文件上傳 (Secure PHP file uploading)

Grails Spring 安全配置通過 xml (Grails Spring Security Configuration thru xml)

醫療應用的安全要求 (Security Requirements for Medical Applications)

如何保護 Silverlight 應用程序 (How to Secure Silverlight Application)

在使用 azure 流量管理器和 azure 應用程序網關與 WAF 時實現國家級阻止 (Achieve country level blocking while using azure traffic manager and azure application gateway with WAF)







留言討論