Lỗi web khi upload lên hosting trong asp.net lúc bị lúc không

Thảo luận trong 'Lập trình web Asp.net' bắt đầu bởi DienDanRaoVat, 19/10/16.

  1. DienDanRaoVat
    Tham gia ngày:
    14/2/14
    Bài viết:
    182
    Đã được thích:
    5
    Điểm thành tích:
    18
    Hi mọi người, mình gặp vấn đề khá khó khăn, không biết giải quyết làm sao. Web mình chạy local khá OK, nhưng khi upload lên hosting, lúc chạy phần quản trị dữ liệu, phần admin, thêm xóa sửa sản phẩm thường bị lỗi như dưới.

    Lỗi này lúc bị lúc không, lúc đang lưu dữ liệu thì bị, khá bực bội.

    Trước kia mình xài OK không sao, tự dung dạo này nó bị hoài, mình nhờ hosting thì họ nói báo về bên lập trình web, bên lập trình thì họ nói lỗi do hosting hizzz, mình không biết làm ntn, đầu tư cái web mà bị lỗi bực quá :((

    Giuppppppppppppp với mọi người ơi. mình cũng biết chút về code, nên chỉ mình cách với

    Lỗi: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster

    Mã:
    Server Error in '/' Application.
    ________________________________________
    Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
    
    See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
    
    See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.
    
    Source Error:
    
    [No relevant source lines]
    
    Source File: c:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\96c4b5e9\43b13487\App_Web_fywircax.0.cs    Line: 0
    
    Stack Trace:
    
    [ViewStateException: Invalid viewstate.
        Client IP: 171.232.175.242
        Port: 62623
        Referer: http://xxxx.com.vn/fx/sialand.aspx
        Path: /Admincp/webconfig.aspx
        User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
        ViewState: /wEPDwUKMTI3MjExMTQ3Mw9kFgJmD2QWAgIDD2QWBAIBDw8WAh4EVGV4dAU7Q2jDumMgYuG6oW4gOiBhZG1pbiBt4buZdCBuZ8OgeSBxdeG6o24gdHLhu4sgdGjDoG5oIGPDtG5nICFkZAIHD2QWFGYPDxYCHwBlZGQCBw8PFgIfAGVkZAIIDw8WAh8AZWRkAhQPDxYCHwBlZGQCFw8PFgQeDkNLRWRpdG9yQ29uZmlnMq9wAAEAAAD/////AQAAAAAAAAAMAgAAAE9DS0VkaXRvci5ORVQsIFZlcnNpb249My42LjYuMiwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1lMzc5Y2RmMmY4MzU0OTk5BQEAAAAbQ0tFZGl0b3IuTkVULkNLRWRpdG9yQ29uZmlnnQAAABNfc2hhcmVkU3BhY2VzQm90dG9tEF9zaGFyZWRTcGFjZXNUb3AlPGF1dG9Hcm93X2JvdHRvbVNwYWNlPmtfX0JhY2tpbmdGaWVsZCM8YXV0b0dyb3dfbWF4SGVpZ2h0PmtfX0JhY2tpbmdGaWVsZCM8YXV0b0dyb3dfbWluSGVpZ2h0PmtfX0JhY2tpbmdGaWVsZCM8YXV0b0dyb3dfb25TdGFydHVwPmtfX0JhY2tpbmdGaWVsZB48YXV0b1BhcmFncmFwaD5rX19CYWNraW5nRmllbGQiPGF1dG9VcGRhdGVFbGVtZW50PmtfX0JhY2tpbmdGaWVsZCA8YmFzZ...]
    
    [HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
    
    See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.]
       System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +116
       System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +425
       System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) +13
       System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +40
       System.Web.UI.HiddenFieldPageStatePersister.Load() +247
       System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +251
       System.Web.UI.Page.LoadAllState() +41
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6211
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
       System.Web.UI.Page.ProcessRequest() +72
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +22
       System.Web.UI.Page.ProcessRequest(HttpContext context) +58
       ASP.admincp_waddnewproducts_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\96c4b5e9\43b13487\App_Web_fywircax.0.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +188
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
    
    
    ________________________________________
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1069.1
    
     
    Cảm ơn đã xem bài:

    Lỗi web khi upload lên hosting trong asp.net lúc bị lúc không

  2. supportviettel
    Tham gia ngày:
    8/6/16
    Bài viết:
    155
    Đã được thích:
    5
    Điểm thành tích:
    18
    Giới tính:
    Nam
    bị lỗi như này , bạn nào có cách khắc phục hiệu quả không, e còn dính lỗi 404 , bác nào biết cách khắc phục chỉ giáo cho e với nhé
     
  3. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,894
    Đã được thích:
    1,198
    Điểm thành tích:
    113
    Giới tính:
    Nam
    HI bạn, lỗi nó báo rõ ràng và cách xử lý của vấn đề rồi kìa bạn. Và lỗi này do cả 2 bên hosting và làm web họ gây ra. Làm web xong up lên mà không xem phiên bản cấu hình của web và hosting có thích hợp hay không.

    1. Lỗi 1 của thông báo kia báo: Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1069.1
    • Lỗi này do phiên bản net framework (dotnet) của bạn khai báo bị sai trong web.config.
    • Lỗi do hosting đang cài đặt khai báo web bạn sử dụng dotnet 4.5 nhưng trong web.config bạn khai báo lại là 4.0
    2. Lỗi : Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster
    • Lỗi do web bạn không sinh được machineKey.
    Cách khắc phục như sau:

    Cách 1:
    • Trước tiên bạn vào web.config tìm xem có đoạn code như thế này không ?
    Mã:
    <compilation debug="true" targetFramework="4.0" />
    

    • Đổi lại code này thành
    Mã:
    <compilation debug="true" />
    

    Cách 2: Nếu làm cách 1 chưa được thì bạn làm tiếp theo cách 2 nhé
    • Vào trang web sau: đế lấy 1 đoạn code và cho vào web.config của web
    Mã:
    http://www.developerfusion.com/tools/generatemachinekey/
    

    • Lấy key xong vào web.config điền vào trong của <system.web> nhé.
    Mã:
    <system.web>
      <machineKey validationKey="94612AF64A75E204ECDAD817D55522785168B46B821E951C2FB62BC3770CF31545DA083BF7586CE7B07C2E7C91309A21DECF091CFBDA3EF039D6E8AFCF7BB41D"
      decryptionKey="AFEEB0DA08EEB3CAB8C587A2B06859A44C7B305646321112FAEBFB265FDD8301"
      validation="SHA1" decryption="AES"/>
      <compilation debug="true" />
    </system.web>
    
    Cách 3: Còn không được nữa thì bạn nói hosting cấu hình web bạn lại xuống từ dotnet 4.5 xuống còn 4.0 là được.

    Chỉ có 3 cách xử lý đó thôi ! chúc bạn thành công !!!
     
    Chỉnh sửa cuối: 12/4/17
    DienDanRaoVat thích bài này.
  4. DienDanRaoVat
    Tham gia ngày:
    14/2/14
    Bài viết:
    182
    Đã được thích:
    5
    Điểm thành tích:
    18
    Cảm ơn ad, mình xử lý theo cách 1 là được rồi, hixx lỗi do cái phiên bản dotnet thế mà mình không nhìn ra hi, căm ơn ad nhiều lắm
     


Chủ để tương tự : Lỗi upload
Diễn đàn Tiêu đề Date
Lập trình web Asp.net Lỗi: The Type or Namespace name 'MVC' does not exits in the 'System.Web' 18/10/21
Lập trình web Asp.net Lỗi .woff2 404 - File or directory not found trên iis windows 15/10/20
Lập trình web Asp.net Lỗi Save Web.Config Configuration file: Access to the path .tmp is denied 10/10/18
Lập trình web Asp.net Lỗi font chữ khi sử dụng CKEditor.NET formatted in utf-8 html encoding 9/2/18
Lập trình web Asp.net Lỗi Format datetime khi tạo sitemap trong c#, asp.net 16/6/17