大家好:我正在创建一个ASP.net项目,这里是一个有问题的文件夹:
Dashboard :
--> DashboardIndex.cshtml
--> DashboardPage.cs
--> DashboardPageModel.cs
我的页面生成以下代码
<div class="small-box bg-aqua">
<div class="inner">
<h3>@Model.OpenOrders</h3>
<p>Open Orders</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
<a href="/IP/1/11_2" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div>
我点击按钮,导致我http://localhost:21739/IP/1/11_2
Aaand ..错误404!
然而,我编码了似乎是合适的函数(我与另一个函数I代码进行了比较(哪个有效),我没有发现任何相关的差异)
namespace Serene7.Common.Pages
{
using Serenity;
using System;
using System.Linq;
using Serenity.Data;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web.UI;
using System.Web.UI.WebControls;
[RoutePrefix("Dashboard"), Route("{action=index}")]
public class DashboardController : Controller
{
[Authorize, HttpGet, Route("~/")]
public ActionResult Index()
{
return View(MVC.Views.Common.Dashboard.DashboardIndex, new DashboardPageModel());
}
[HttpGet]
[Route("IP/{Station=0}/{Timestp=0}")]
public ActionResult IP(int station, string timestp)
{
timestp = timestp.Replace("_", ":");
SqlConnection myConn = new SqlConnection(@"Server=(LocalDb)\MSSqlLocalDB;Integrated security=SSPI;database=Serene7_Default_v1");
List<string> listeIps = new List<string>();
string listDb = string.Format("SELECT DISTINCT (IpSource) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE Station = '{0}' AND TimeStp = '{1}';",station,timestp);
SqlCommand myCommand = new SqlCommand(listDb, myConn);
string listDb2 = string.Format("SELECT DISTINCT (IpSource,IpDestination) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE Station = '{0}' AND TimeStp = '{1}';", station, timestp);
SqlCommand myCommand2 = new SqlCommand(listDb2, myConn);
myConn.Open();
SqlDataReader reader = myCommand.ExecuteReader();
while (reader.Read())
{
listeIps.Add(reader[0].ToString());
}
reader.Close();
SqlDataReader reader2 = myCommand.ExecuteReader();
while (reader2.Read())
{
listeIps.Add(reader2[0].ToString());
}
List<string> noRepetitions = listeIps.Distinct().ToList();
int lengthList = noRepetitions.Count;
byte[] imageBuffer = new byte[400 * lengthList * lengthList * 4];
string listDb3 = string.Format("SELECT SUM(ToTheRight) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE IdSource = @IdSource AND IdDestination = @IdDestination AND Station = '{0}' AND TimeStp = '{1}';", station, timestp);
string listDb4 = string.Format("SELECT SUM(ToTheLeft) FROM [Serene5_Default_v1].[tcpdump].[TCPDump] WHERE IdDestination = @IdSource AND IdSource = @IdDestination AND Station = '{0}' AND TimeStp = '{1}';", station, timestp);
SqlCommand myCommand3 = new SqlCommand(listDb3, myConn);
SqlCommand myCommand4 = new SqlCommand(listDb4, myConn);
IDbDataParameter param;
param = myCommand3.CreateParameter();
param.ParameterName = "@IdDestination";
param.Value = "''";
param = myCommand3.CreateParameter();
param.ParameterName = "@IdSource";
param.Value = "''";
param = myCommand4.CreateParameter();
param.ParameterName = "@IdDestination";
param.Value = "''";
param = myCommand4.CreateParameter();
param.ParameterName = "@IdSource";
param.Value = "''";
int[,] matrix = new int[lengthList, lengthList];
for (int x = 0; x < lengthList; x++)
{
for (int y = 0; y < lengthList; y++)
{
myCommand3.Parameters["@IdSource"].Value = "'" + noRepetitions[x] + "'";
myCommand3.Parameters["@IdDestination"].Value = "'" + noRepetitions[y] + "'";
myCommand4.Parameters["@IdSource"].Value = "'" + noRepetitions[x] + "'";
myCommand4.Parameters["@IdDestination"].Value = "'" + noRepetitions[y] + "'";
int total = 0;
SqlDataReader reader3 = myCommand3.ExecuteReader();
SqlDataReader reader4 = myCommand4.ExecuteReader();
while (reader3.Read())
{
total += (int)reader[0];
}
reader3.Close();
while (reader4.Read())
{
total += (int)reader[0];
}
reader4.Close();
matrix[x, y] = total;
}
}
int maximum = matrix.Cast<int>().Max();
double logMax = Math.Log(maximum);
for (int x = 0; x < 20 * lengthList; x++)
{
for (int y = 0; y < 20 * lengthList; y++)
{
int posX = x % 20;
int posY = y % 20;
int offset = ((20 * lengthList * 4) * y) + (x * 4);
int test = 0;
if (matrix[x, y] > 0)
{
test = 1;
}
int value = (int)(test * (10 + (245 * Math.Log(matrix[x, y]) / logMax)));
imageBuffer[offset] = (byte)value;
imageBuffer[offset + 1] = (byte)value;
imageBuffer[offset + 2] = (byte)value;
imageBuffer[offset + 3] = 255;
}
}
unsafe
{
fixed(byte* ptr = imageBuffer)
{
using (Bitmap image = new Bitmap(256, 100, 256 * 4,
PixelFormat.Format32bppRgb, new IntPtr(ptr)))
{
image.Save(@"C:\Users\FS091843\Desktop\Stations\Station1\greyscale.png");
}
}
}
DashboardPageModel dashboard = new DashboardPageModel();
return View(MVC.Views.Common.Dashboard.DashboardIndex, dashboard);
}
}
}
任何人都知道出了什么问题?