.net - Can I create a route which redirects "/" to another folder with static HTML files in it? -



.net - Can I create a route which redirects "/" to another folder with static HTML files in it? -

i'm using webapi, , have route setup "api/{controller}/{id}". have next folder construction in project:

\static\index.html \static\pagey.html

i want web site's users able go to:

http://localhost/index.html http://localhost/pagey.html

is should avoid doing in first place? if no, there way create such route definition?

if you're running on owin, can without touching web api routing. should able utilize microsoft.owin.staticfiles middleware this. illustration setup class:

public class startup { public void configuration(iappbuilder app) { var webapiconfig = new httpconfiguration(); // web api routing setup here... app.usewebapi(config); var assemblypath = assembly.getexecutingassembly().location; var assemblyfolder = path.getdirectoryname(assemblypath); var staticfolder = path.combine(exefolder, "static"); app.usestaticfiles(webfolder); } }

this serve static files <dll folder>\static folder. if app @ c:\myapp, hitting http://localhost/index.html, serve c:\myapp\static\index.html static html.

.net owin asp.net-web-api-routing

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -