[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/var/www/helloapp
ExecStart=/usr/bin/dotnet /var/www/helloapp/helloapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
[Unit]
Description=siteRestartService
[Service]
Type=simple
ExecStart=/usr/local/bin/siteRestart.sh
[Install]
WantedBy=multi-user.target
[Unit]
Description=RestartSiteDaily
[Timer]
OnCalendar=daily
Unit=siteRestart.service
Persistent-true
[Install]
WantedBy=multi-user.target
#!/bin/bash
systemctl restart site.service
<div class="container">
<h1>Регистрация на сайте</h1>
<form action="#" method="post" id="form_UserRegistration">
<label for="input_UserName">Имя</label>
<input type="text" name="UserName" id="input_UserName" />
<label for="input_UserEmail">Email</label>
<input type="text" name="UserEmail" id="input_UserEmail" />
<label for="input_UserAge">Возраст</label>
<input type="number" name="UserAge" id="input_UserAge" />
<button type="submit">Зарегистрироваться</button>
</form>
</div>
<script>
const form = document.getElementById('form_UserRegistration');
fetch('http://localhost:24068/home/index', {
method: 'POST',
body: JSON.stringify(Object.fromEntries(new FormData(form)))
}).then(function (response) {
// Стоит проверить код ответа.
if (!response.ok) {
// Сервер вернул код ответа за границами диапазона [200, 299]
return Promise.reject(new Error(
'Response failed: ' + response.status + ' (' + response.statusText + ')'
));
}
// Далее будем использовать только JSON из тела ответа.
return response.json();
}).then(function (data) {
console.log(data);
}).catch(function (error) {
console.log(error);
});
</script>
[HttpPost]
public async Task<IActionResult> Index(IFormCollection form)
{
var createSql = @"INSERT INTO UsersTable (UserName, UserEmail, Age) VALUES (@UserName, @UserEmail, @Age)";
var usersSql = @"SELECT * FROM UsersTable";
using (var connection = new SqlConnection(CONNECTION_STRING))
{
var usersCreate = await connection.QueryAsync<UserModel>(createSql, new { @UserName = form["UserName"], @UserEmail = form["UserEmail"], @Age = form["UserAge"] });
var usersTable = await connection.QueryAsync<UserModel>(usersSql);
return View(usersTable);
}
}
<div class="map">
<img src="img.png" class="map maphilighted" usemap="#simple">
</div>
<map name="simple">
<area id="first" class="all" shape="poly" coords="78,14,75,29,71,3,20,96,28">
<area id="second" class="all" shape="poly" coords="73,38,50,4,79,118,62,105,48,95,41">
</map>
<div class="data">
</div>
$(document).ready(function(){
$('.all').click(function() {
var name = ($(this).attr('id'));
$.ajax({
url: 'a.php',
method: 'post',
dataType: 'html',
data: {name:name},
success: function(data){
$('.data').html(data);
}
});
return false;
});
});
if($_POST['name'] == 'first') {
echo 'Это первый';
} elseif($_POST['name'] == 'second') {
echo 'Это второй';
}