با سلام و احترام
برنامه من با دات نت کور 2 نوشته شده خواستم بر روی هاست بارگذاری کنم با خطای زیر مواجه شدم
با خدمت دهنده هاست صحبت کردم گفتن کور بر روی سرور نصب هست اشکال از کد نویسی شماست !!
سهیل عزیز راهنمایی کردند کردند web.config رو اصلاح کنم .با
<environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables>
دیتابیس روی plesk ساختم هم نام به دیتابیس خودم و نمی دونم باید برنامه ران بشه تا تیبل های برنامه ساخته بشن ؟ یا کار دیگه ای باید انجام بدم .
اما بازم خطا دارم ERROR 500
دوستان به صورت جامع می تونند راهنمایی کنند .
این مقاله رو هم خوندم. کمکی نکرد.
هاست با Plesk مدیریت میشه .
محتوای فایل startup رو قرار بدید.
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using DrBND.Data; using DrBND.Models; using DrBND.Services; using Microsoft.Extensions.FileProviders; using System.IO; namespace DrBND { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); //------------------------------------------ //----------------------------------تنظیمات رول------------------------ //Password Strength Setting services.Configure<IdentityOptions>(options => { // Password settings options.Password.RequireDigit = true; options.Password.RequiredLength = 6; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequireLowercase = false; options.Password.RequiredUniqueChars = 0; // Lockout settings options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(60); options.Lockout.MaxFailedAccessAttempts = 10; options.Lockout.AllowedForNewUsers = true; // User settings options.User.RequireUniqueEmail = false; }); //Setting the Account Login page services.ConfigureApplicationCookie(options => { // Cookie settings options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(30); options.LoginPath = "/Home/Login"; // If the LoginPath is not set here, // ASP.NET Core will default to /Account/Login options.LogoutPath = "/Home/Logout"; // If the LogoutPath is not set here, // ASP.NET Core will default to /Account/Logout options.AccessDeniedPath = "/Home/AccessDenied"; // If the AccessDeniedPath is // not set here, ASP.NET Core // will default to // /Account/AccessDenied options.SlidingExpiration = false; }); //------------------------------------------------------------------------------ // Add application services. services.AddTransient<IEmailSender, EmailSender>(); services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); //---------------------- //CreateUserRoles(services).Wait(); } //private async Task CreateUserRoles(IServiceProvider serviceProvider) //{ // var RoleManager = serviceProvider.GetRequiredService<RoleManager<IdentityRole>>(); // var UserManager = serviceProvider.GetRequiredService<UserManager<ApplicationUser>>(); // IdentityResult roleResult; // //Adding Admin Role // var roleCheck = await RoleManager.RoleExistsAsync("Admin"); // if (!roleCheck) // { // //create the roles and seed them to the database // roleResult = await RoleManager.CreateAsync(new IdentityRole("Admin")); // } // //Assign Admin role to the main User here we have given our newly registered // //login id for Admin management // ApplicationUser user = await UserManager.FindByEmailAsync("syedshanumcain@gmail.com"); // var User = new ApplicationUser(); // await UserManager.AddToRoleAsync(user, "Admin"); //} } }
در کلاس Startup همه چی درست به نظر میرسه. لطفا Web.config رو به طور کامل قرار بدید.
<?xml version="1.0" encoding="utf-8"?> <configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\DrBND.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables> </system.webServer> </location> </configuration>
Environment را داخل aspNetCore قرار نداده بودید:
<aspNetCore processPath="dotnet" arguments=".\DrBND.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"> <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables> </aspNetCore>
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)