2014-08-28 57 views
0

我嘗試將數據發佈到遠程服務器(Windows Server 2012 R2,IIS 7),並且只有一個類無法正常工作我收到(錯誤403),但是我的數據存儲在我的sqlite文件中。錯誤403嘗試將數據POST到Web服務

我不知道我的這部分代碼:

 public object Post(PatientSessionADD request) 
    { 
     PatientSessionCRUDFunctions PSCF = new PatientSessionCRUDFunctions(Db); 
     PatientDetailsCRUDFunctions PDCF = new PatientDetailsCRUDFunctions(Db); 

     // Create the new Session 

      // Start Session 
      var p = new PatientSession() 
      { 
       ByPatientId = request.ByPatientId, 
       PatientStartSessionTime = request.PatientStartSessionTime, 
       PatientStartSessionByUserId = request.PatientStartSessionByUserId 
      }; 

      patientsessionid = PSCF.AddPatientSession(p); 

      // --- Generate folder + Images --- 
      // Get AgeBlock 
      var PatientDetails = PDCF.GetPatientDetailsByID(p.ByPatientId); 
      string ageblock = PatientDetails.AgeBlock; 
      // Generate path with Session ID 
      pdp.GeneratePath(patientsessionid); 
      // Call image generator and create images 
      TempImageCreationClass.GenerateChartImage(Convert.ToInt32(ageblock)); 

      // Return a JSON Response 
      return new PatientSessionADDResponse 
      { 
       PatientSessionId = patientsessionid 
      };} 

當我直接打電話給我的功能AddPatientSession從我的JSON響應,我沒有得到錯誤403 有我在這裏的功能在數據庫中添加數據:

public class PatientSessionCRUDFunctions 
{ 
    // The IDbConnection passed in from the IOC container on the service 
    System.Data.IDbConnection _dbConnection; 

    // Store the database connection passed in 
    public PatientSessionCRUDFunctions(System.Data.IDbConnection dbConnection) 
    { 
     _dbConnection = dbConnection; 
    } 

    // Inserts a new row into the PatientSession table 
    public int AddPatientSession(PatientSession p) 
    { 
     return (int)_dbConnection.Insert<PatientSession>(p, selectIdentity: true); 
    } 
} 

此外,當我在本地測試我的代碼我的課的工作,所以我檢查IIS權限,我沒有發現我的問題什麼。這真是令人困惑,因爲我不知道問題來自我的代碼還是來自IIS。

你看到了什麼問題嗎?謝謝

+2

如果它在本地工作,那麼問題將是IIS。如果你查看錯誤413,你會發現它是一個'Request Entity too Large',這不是ServiceStack錯誤。這可能意味着您嘗試上傳超過IIS設置限制的大文件。 [詳情請參閱此處](http://blogs.msdn.com/b/jiruss/archive/2007/04/13/http-413-request-entity-too-large-can-t-upload-large- files-using-iis6.aspx) – Scott 2014-08-28 17:43:52

+0

我真的很抱歉@Scott我犯了一個錯誤,我得到錯誤「403」。對不起,我什麼都很累,當我把我的問題 – Ben 2014-08-29 12:58:31

+0

好吧我修復IIS權限問題,謝謝@Scott,但爲什麼我有這個問題(錯誤403)只爲這個類。在這個實現中,我得到另一個表的ID來連接我的表和一個連接。我用一個函數來得到它也許它可能是這個?如果我找到答案,我會發布它我很確定它不僅僅是IIS權限 – Ben 2014-09-01 13:33:07

回答

1

我終於發現我的問題是關於IIS身份驗證,我啓用所有類型的身份驗證,這可能不是最好的想法做,但我不會再遇到這個錯誤。 enter image description here

+0

只激活「匿名身份驗證」和「ASP.NET模擬」已足夠 – Ben 2014-09-24 15:08:10

相關問題