我想根据数据集的结果重定向到不同的视图,但我一直回到我当前所在的页面,并且无法解决原因.我进入if语句调用操作但是一旦我将视图返回到新页面,它就会返回到当前页面.
CSHTML页面
@{
ViewBag.Title = "Search Results";
EnumerableRowCollection<DataRow> custs = ViewBag.Customers;
bool anyRows = custs.Any();
if(anyRows == false)
{
Html.Action("NoResults","Home");
}
// redirect to no search results view
Run Code Online (Sandbox Code Playgroud)
}
调节器
public ActionResult NoResults()
{
return View("NoResults");
}
Run Code Online (Sandbox Code Playgroud)
查看我也无法得到..
@{
ViewBag.Title = "NoResults";
}
<h2>NoResults</h2>
Run Code Online (Sandbox Code Playgroud) 我是 MOQ 的新手,我对设置方法有点困惑。下面的示例显示了我需要测试的一种方法。被测方法返回两个日期的最新时间,因此我创建了两个 datetime 对象并将它们传递给我的函数。我感到困惑的部分是返回调用。这会忽略我的方法中的逻辑并返回我告诉它的内容。例如,如果我说返回(date2),那么无论逻辑如何,断言都会通过。难道我做错了什么?
public virtual DateTime LatestTime(DateTime t1, DateTime t2)
{
if (t1.CompareTo(t2) > 0)
return t1;
return t2;
}
[Test]
[Category("Catalogue service")]
public void TestLatestTimeReturnsCorrectResult()
{
//Arrange
DateTime date1 = new DateTime(2014, 07, 25, 13, 30, 01);
DateTime date2 = new DateTime(2014, 07, 25, 13, 30, 00);
MockCatalogueService.Setup(x => x.LatestTime(date1, date2)).Returns(date2);
//Act
DateTime retDate = MockCatalogueService.Object.LatestTime(date1, date2);
//Assert
Assert.That(retDate == date2);
}
Run Code Online (Sandbox Code Playgroud) 无法让 wpf 项目重新识别FolderBrowserDialog
using System.Windows.Forms.Integration;
using System.Windows.Forms;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
FolderBrowserDialog browse = new FolderBrowserDialog();
}
Run Code Online (Sandbox Code Playgroud)
无法找到类型或名称空间FolderBrowserDialog???
将一个参数传递给控制器是空的..从我看到的使用正确的重载的例子.任何有用的帮助
@{
foreach (string str in ViewBag.ServerNames)
{
<ul>
<img src="../../Content/Images/my_computer.png" alt="Computer Name"/>
<li >@Html.ActionLink(linkText: str.ToString(),actionName: "Index",controllerName:"Customer",
routeValues:new{str = str.ToString()} , htmlAttributes: null)</li>
</ul>
}
Run Code Online (Sandbox Code Playgroud)
}
public ActionResult Index(string conName)
{
Response.Write("con name = " + conName);
Response.End();
string con = ConfigurationManager.ConnectionStrings[conName].ConnectionString;
trakman_Entities db = new trakman_Entities(con);
return View(db.customers.ToList());
}
Run Code Online (Sandbox Code Playgroud)
浏览器源代码
<ul>
<img src="../../Content/Images/my_computer.png" alt="Computer Name"/>
<li ><a href="/Customer/Index/DefaultConnection">DefaultConnection</a></li>
</ul>
<ul>
<img src="../../Content/Images/my_computer.png" alt="Computer Name"/>
<li ><a href="/Customer/Index/trakman_Entities">trakman_Entities</a></li>
</ul>
<ul>
<img src="../../Content/Images/my_computer.png" alt="Computer Name"/>
<li ><a href="/Customer/Index/trakman_Entities1">trakman_Entities1</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我正在传递一个 int pthread_create 类型的数组并收到错误:
histogram.c:138:3: warning: passing argument 3 of
‘pthread_create’ from incompatible pointer type [enabled by default]
expected ‘void * (*)(void *)’ but argument is of type ‘void * (*)(int *)’
void *output_results();
pthread_create(&t2, NULL, output_results, (void *)bins);
void *output_results(int *bins) {
some code
}
Run Code Online (Sandbox Code Playgroud) 我有一个功能来添加向量和存储结果,我无法解决为什么我得到分段核心转储.暂时不做C:/
void add(int *a, int *b, int *c, int n){
int i;
for(i = 0 ; i < n; n++)
{
c[i] = a[i] + b[i];
i++;
}
}
int main() {
// vector_size = 100000
// vector_a init with 100000 values
// vector_b init with 100000 values
int *result = malloc(vector_size * sizeof(int));
add(vector_a,vector_b,result,vector_size);
}
Run Code Online (Sandbox Code Playgroud) c# ×4
arrays ×2
c ×2
actionresult ×1
asp.net-mvc ×1
malloc ×1
mocking ×1
moq ×1
pthreads ×1
razor ×1
unit-testing ×1
wpf ×1