服务器中的上载问题 [英] Uploadin problem in a server

查看:123
本文介绍了服务器中的上载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用登录页面.登录后,我可以在我的域中上传一些文件或数据.但是,当我大部分时间上载时,它会失败并显示以下错误,并且上载时间也很长.如何减少时间,如何克服以下问题?

I am using a login page. After login I can Upload some file or data in my domain. But when I uploading most of the time it fails and shows following errors an also it takes long time to upload. How can I reduce the time and also how can I over come the following problem?

Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 17:     protected void Page_Load(object sender, EventArgs e)
Line 18:     {
Line 19:         Session["user_id"].ToString();
Line 20:     }
Line 21:     protected void Page_Init(object sender, EventArgs e)


Source File: c:\hostingspaces\bhimpurs\bhimpurswamijividyapith.co.in\wwwroot\ADMIN\Admin_MasterPage.master.cs    Line: 19 

推荐答案

如果花费了这么长时间,然后您的会话可能已过期,在这种情况下,您可能会收到此错误.您可以尝试将会话持续时间设置为更高的值: MSDN [ ^ ],但正如它所说的,这是个坏主意.

而不是会话,为什么不将用户ID存储在cookie中?
If it is taking that long, then your session may have expired, in which case you could get this error. You can try setting the session duration to a higher value: MSDN[^] but as it says, this is a bad idea.

Instead of the session, why not store the user ID in a cookie?


对象引用未设置为对象的实例

当您尝试使用属性或调用对象的方法为null时,会发生此错误.更多详细信息:此处 [
Object reference not set to an instance of an object

This error happens when you try to use a property or call a method of an object that is null. More details: here[^]

A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line (Here line19). Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.

It looks like your session is getting timedout and hence when you try to use it, it throws an exception. 2 things:
1. You should always check for null with sessions before using as a good practice
2. if it is taking really such a long time (session timeout default time 20 min) then you need to increase the timeout in your web.config file, like:
Write under system.web section in web.config (for say 60 minutes):
<sessionState timeout="60" mode="InProc" />



参考:
MSDN:sessionState元素(ASP.NET设置架构) [ ^ ]



Refer: MSDN: sessionState Element (ASP.NET Settings Schema)[^]


这篇关于服务器中的上载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆