小编Maz*_*aie的帖子

如何通过WebApi上传图像

如何通过ASP.NET Web API上传图像文件?
我在文件模式下有一个输入标签,它发布到API,我如何将其保存到服务器文件夹?
我试过这段代码,但它不起作用:

private void UploadWholeFile(HttpRequestBase request)
{
   for (int i = 0; i < request.Files.Count; i++)
   {
      var file = request.Files[i];

      var ext = new FileInfo(file.FileName).Extension;
      var fullPath = Path.Combine(StorageRoot, Path.GetFileName(Guid.NewGuid() + ext));

      file.SaveAs(fullPath);
   }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api

22
推荐指数
2
解决办法
7万
查看次数

构建后缺少组装

我的C#解决方案中有5个项目.

  1. 共同
  2. 数据访问.
  3. UI
  4. 组件
  5. 测试

我可以添加对Components.dll的引用.但是,当我运行解决方案时,我得到了错误:

类型或命名空间名称"组件"不存在.

Components.dll是在引用文件夹中已经存在.

你能帮帮我吗?

这是构建输出:

------ Rebuild All started: Project: Comps, Configuration: Release Any CPU ------
  Comps -> ..\Ashyaneh\Comps\bin\Release\AshyanehComps.dll
------ Rebuild All started: Project: Interfaces, Configuration: Debug Any CPU ------
  Interfaces -> ..\Ashyaneh\Interfaces\bin\Debug\AshyanehInterfaces.dll
------ Rebuild All started: Project: Common, Configuration: Debug Any CPU ------
  Common -> ..\Ashyaneh\Common\bin\Debug\AshyanehCommon.dll
------ Rebuild All started: Project: Web, Configuration: Debug Any CPU ------
  Web -> E:\My Programming 1391\HRShojaieWebAppRC2\Ashyaneh\Web\bin\Web.dll
------ Rebuild All started: Project: Test, Configuration: Debug x86 …
Run Code Online (Sandbox Code Playgroud)

c#

5
推荐指数
1
解决办法
9999
查看次数

在javascript中设置innerHTML并从C#获取

我有两个标签:

  <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
  <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
Run Code Online (Sandbox Code Playgroud)

我通过javascript设置innerHTML:

document.getElementById('Label1').innerHTML = position.lat();
document.getElementById('Label2').innerHTML = position.lng();
Run Code Online (Sandbox Code Playgroud)

我如何在代码隐藏中获得这些标签值?我尝试:

TextBox2.Text = Label1.Text;
Run Code Online (Sandbox Code Playgroud)

更新:我需要获取图钉位置:

  <artem:GoogleMap ID="GoogleMap1" runat="server" 
    EnableMapTypeControl="False" MapType="Roadmap" >        
  </artem:GoogleMap>      
  <artem:GoogleMarkers ID="GoogleMarkers1" runat="server" 
    TargetControlID="GoogleMap1" onclientpositionchanged="handlePositionChanged">
  </artem:GoogleMarkers> 
  <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
  <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>

<script type="text/javascript">
  var list = document.getElementById("Label1");
  function handlePositionChanged(sender, e) {
    printEvent("Position Changed", sender, e);
  }
  function printEvent(name, sender, e) {
    var position = e.latLng || sender.markers[e.index].getPosition();
    document.getElementById('Label1').innerHTML = position.lat();
    document.getElementById('Label2').innerHTML = position.lng();
  }
</script>

protected void Button1_Click(object …
Run Code Online (Sandbox Code Playgroud)

c# innerhtml

3
推荐指数
1
解决办法
7396
查看次数

ASP.NET和EF非常慢

通过使用EF,C#和ASP.NET 4 Web应用程序,我使用以下代码从数据库中检索数据并填充GridView:

using (AshModel am = this.conn.GetContext())
{
    IEnumerable<Article> articles = 
        (from a in am.Article.AsEnumerable()
         where (a.CultureName == calture || a.CultureName == 0)
             && a.IsApproved == status
             && a.IsPublished == status
         orderby a.AddedDate descending
         select a);

    IEnumerable<Profile> profiles = am.Profile.AsEnumerable()
        .Where(t => articles.Any(a => a.ProfileId == t.ProfileID));

    foreach (Article article in articles)
        article.UserProfile = profiles
            .Where(a => a.ProfileID == article.ProfileId)
            .FirstOrDefault();

    this.gvArticles.DataSource = articles.ToList();
    this.gvArticles.DataBind();
}
Run Code Online (Sandbox Code Playgroud)

但它非常慢,响应大约需要2分钟,数据库中只有500条记录!我的错误是什么?我如何才能提高绩效?谢谢.

c# asp.net entity-framework

3
推荐指数
1
解决办法
239
查看次数

我有一个错误,无法将对象从DBNull强制转换为其他类型?

我的代码是:我在做断点时正在检索数据氟利昂数据库,它显示列表中的数据,但是它也给我一个错误

    public static List<StudentScore> GetAllScore()
   {
       SqlConnection conn = MyDB.GetConnection();
       string selectStm = "SELECT en.CourseID,en.Score,s.StudentID FROM EnrollmentTable en,Student s WHERE en.StudentID = s.StudentID";
       SqlCommand command = new SqlCommand(selectStm, conn);
       List<StudentScore> aStudentScore = new List<StudentScore>();
       try
       {
           conn.Open();
           SqlDataReader reader = command.ExecuteReader();          
           Console.WriteLine(reader.HasRows.ToString());
           while (reader.Read())
           {
               StudentTable st = new StudentTable();
               CourseTable cr = new CourseTable();
               Enrollment enr = new Enrollment();
               StudentScore score = new StudentScore();
               enr.CourseData = cr;
               enr.StudentData = st;                                    
                   //score.EnrollmentData.StudentData.StudentID = reader["StudentID"].ToString();
                   //score.EnrollmentData.CourseData.CourseID = reader["CourseID"].ToString();                  
                   st.StudentID = reader["StudentID"].ToString(); …
Run Code Online (Sandbox Code Playgroud)

c# c#-to-vb.net c#-3.0 c#-4.0

0
推荐指数
1
解决办法
7064
查看次数