所以我使用这个调用我的操作结果方法:
var url= "/Example/Controler/1/Action";
$("<form action='"+url+"'></form>").submit();
Run Code Online (Sandbox Code Playgroud)
但是没有调用动作方法...我也试过这个
$.post(url, function (data) {});
Run Code Online (Sandbox Code Playgroud)
这有效,我们调用控制器,但页面不刷新......
我的操作方法如下所示:
public ActionResult DoStuff(int Id)
{
.....
return RedirectToAction("index", new { Id });
}
Run Code Online (Sandbox Code Playgroud) 我需要在这个时间戳上获取一列“温度”的前 5 个值,例如“按 desc 选择 tbl_sensors 顺序的前 5 个温度”
我尝试了这样的方法,但不知道如何进入前5名
var sensorsVal = DB.tbl_sensors.OrderByDescending(x => x.CurrentTime).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud) 我使用MVC为登录系统脚本编写tis代码
这是数据库类
<?php
class Database
{
private $host;
private $user;
private $password;
private $database;
function __construct($filename)
{
if (is_file($filename))include $filename;
else throw new Exception("Error!");
$this->host =$host;
$this->user =$user;
$this->password =$password;
$this->database =$database;
$this->connect();
}
//Connect the server
private function connect()
{
$conn=mysqli_connect($this->host, $this->user, $this->password, $this->database);
//Check Connection
if(!$conn)
throw new Exception("Error: not connect to the server");
// Select the database
if(!mysqli_select_db($conn,$this->database))
throw Exception("Error!");
}
//Close dataabase connection
function close()
{
mysqli_close();
}
}
?>
Run Code Online (Sandbox Code Playgroud)
当我调用此代码
<?php
/*
//Site login Controller …Run Code Online (Sandbox Code Playgroud) 我在项目工作时遇到过这个问题,我无法理解如何解决这个问题
![] [1]
routes.MapRoute(
name: "MoviesByReleaseDate",
url: "movies/byreleasedate/{year}/{month}",
defaults: new
{
controller = "Movies",
action = "ByReleaseDate",
},
new { year = @"/d={4}", month = @"/d={2}" }
);
Run Code Online (Sandbox Code Playgroud) 我有这个路由:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{culture=en-US}/{controller=Home}/{action=Index}/{p1?}/{p2?}");
});
Run Code Online (Sandbox Code Playgroud)
最后两个项是可选的,实际上它们在大多数页面中都不存在,并且是针对特定页面的(我也希望它是登录页面)但是它不允许为可选参数定义值.
我试过{p1?=somevalue},我得到一个错误,告诉我?必须是最后一个角色.{p1=somevalue?}也不起作用.
有什么办法可以删除输入(type =“ number”)中的这些?
<input type="number" />Run Code Online (Sandbox Code Playgroud)
供用户输入他们的电话号码。
我正在使用 django 2.0.2 开发一个简单的 Web 应用程序。我不确定我的代码有什么问题。我收到错误
ModuleNotFoundError: No module named 'myapp.views.hello'; 'myapp.views' is not a package
Run Code Online (Sandbox Code Playgroud)
这是我的代码
视图.py
from django.shortcuts import render
def hello(request):
return render(request,'myapp/templates/hello.html',{})
Run Code Online (Sandbox Code Playgroud)
网址.py
from django.contrib import admin
from django.urls import path
from django.conf.urls import include
urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', include('myapp.views.hello'), name='hello'),
]
Run Code Online (Sandbox Code Playgroud)
即使我做了同样的错误 from myapp.views import *
我的代码有什么问题?
这是树结构
DjProject/
??? db.sqlite3
??? DjProject
? ??? __init__.py
? ??? __pycache__
? ? ??? __init__.cpython-36.pyc
? ? ??? settings.cpython-36.pyc
? ? ??? urls.cpython-36.pyc
? ? …Run Code Online (Sandbox Code Playgroud) 因此,从本质上讲,我希望能够将多个参数传递给一个函数。其中之一是可选的,我也希望它采用任何类型的变量。
我该怎么做才能做到这一点呢?
public new object Session (String strSession, Type objValue = null)
{
// Execute logic
}
Run Code Online (Sandbox Code Playgroud)
要么
public new object Session <T> (String strSession, objValue<T> = null)
{
// Execute logic
}
Run Code Online (Sandbox Code Playgroud)
不明白为什么这被否决了。我提供了清晰的代码段,不是吗?
我在 c#.net mvc 中使用 bootstrap-vue.css 库、vue.js、bootstrap-vue.js、bootstrap.css 和 bootstrap.js 与 razor。我可以使用哪个 vue 库而不会有任何冲突?不需要jquery。
我目前正在使用
<div>
<b-navbar toggleable="lg" type="dark" variant="info">
</b-navbar>
</div>
Run Code Online (Sandbox Code Playgroud)
代替
<mdb-navbar color="indigo" dark>
</mdb-navbar>
Run Code Online (Sandbox Code Playgroud)
目前我有 pdf 文件可以正确显示在页面上,但 URL 显示为“/Test?id=name.pdf”,我希望它显示为“/Test/name.pdf”。我怎样才能做到这一点?
这是我的代码:
.cshtml
<a class="dropdown-item" href="@Url.Action("Trees", "Park", new { id = "name.pdf" })" target="_blank">Text</a>
Run Code Online (Sandbox Code Playgroud)
控制器
public ActionResult Trees(string id)
{
string path = Server.MapPath(String.Format("~/folder1/folder2/{0}", id));
string mime = MimeMapping.GetMimeMapping(path);
return File(path, mime);
}
Run Code Online (Sandbox Code Playgroud)
路由配置文件
routes.MapRoute(
name: "testing",
url: "Test/{filename}",
defaults: new { controller = "Park", action = "Trees", filename = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
知道我做错了什么吗?我已经检查了这些类似的问题ASP.NET MVC 路由问题 如何摆脱ASP.NET MVC 路由中的问号?但这些解决方案都没有帮助我,也许是因为我有一个 @Url.Action 和 new { id = "name.pdf" } 这可能是不同的,因为这些问题都没有。
任何建议表示赞赏。谢谢。
c# ×7
asp.net-mvc ×4
asp.net ×3
django ×1
django-views ×1
javascript ×1
jquery ×1
linq ×1
login ×1
optional ×1
php ×1
python ×1
python-3.x ×1
razor ×1
routes ×1
routing ×1
types ×1
vue.js ×1