编译器错误:名称空间'System'中不存在类型或命名空间名称'Core'(您是否缺少程序集引用?)

时间:2011-08-03 04:59:39

标签: c# asp.net

我尝试在c#中的项目中上传图像。我在提交按钮中的代码如下:

FileUpload1.SaveAs(
          Server.MapPath("Photos\\" + 
              System.Core.WebSecurity.GetUserName(Request) + ".jpg"));

Response.Write(
    "<html> <script> alert ( 'you have successfully uploaded' ); </script></html>");

Response.Redirect("studentcreated.aspx");

但在编译时会显示错误

  

命名空间中不存在类型或命名空间名称“Core”   '系统'(你错过了一个程序集参考吗?)   

然后我尝试通过添加system.core来解决这个问题。但它仍然显示相同的错误。我使用的是vs2008 asp3.5。

1 个答案:

答案 0 :(得分:0)

尝试此操作以获取用户名:User.Identity.Name

编辑: 添加此引用:using System.Web.Security;