I am working on a asp.net project with react and want to use react-router. On its git repo the setup is only explained for Node.js. I found the TypeScript packages of NuGet but after installing them, I cannot build my project anymore due to compilation errors.
Does anyone have experience with installing react-router for asp.net projects?
What we did to build our application in React. We created our whole application in React in Visual Studio Code with Redux and React-Router. Webpack is used to build all the files. Once whole application is completed, we build the js (transpiled and minified) and added a script tag pointing to that url of the bundle js into our web application page (specifically .aspx page).
Now issues you might face with react-router, if you have hosted it inside a directory of your existing project. For e.g. inside root - you have folder named myapp. If that is the case - you need to make changes to your Routes in your react app to have a base name.
I tried React.NET but after doing it this way - I really liked this approach as you can separately build the whole application with all the awesome tools you have in client side ecosystem - for instance - hot reloading
Hope it helps.
I have never used React.NET, but what you can do is create a separate project, outside of your ASP.NET project. Use webpack for bundling and other purposes. Build your react project, which generates static assets (main.js, chunks, css files and images/sprites). Add these generated files in your ASP.NET project directly and set index.html as Start Page.
We have built our React project on top of this boilerplate. It uses industry-grade ways of optimization, uglification, minification, bundling and what not! Good luck!
Related
I have two ASP.NET web projects and they share a lot of images and JavaScript files. I tried to create a shared project and linking it into both ASP.NET csproj files:
<Import Project="..\Shared\Shared.projitems" Label="Shared" />
But images inside the shared project are not found during debugging with IIS (Browsers "image not found" image is displayed). But Visual Studio recognized them and showing the image files in IntelliSense.
Any ideas?
You still can bundle resources with project and distribute it, but you nee to create nuget package.
create project
make nuget package
publish it to private feed (e.g. myget.org)
add reference to your feed from client projects
PS: Only content of folder 'Content' included in nuget package.
Apologies for the speculative answer, but hopefully this will help someone;
This is a struggle I'm currently facing too (which is concerning, as nearly two years have passed with barely a mention).
I have also had to manually add the Import line to each solution as it appears you have.
I think the issue is with the inbuilt debugger not knowing how to serve the files properly. If you deploy the compiled solution to any instance of IIS it appears to work correctly.
I am experimenting with the inbuilt debugger to see if I can get it to work, but am quite confident I'll have to use a local IIS instance moving forward.
Shared projects provide invaluable functionality, so it's a shame it's still not natively supported.
At the end of the day your images have to actually be somewhere, you can't just reference them from another project. It would work if this other project was hosted in IIS, given a domain, and you referenced the images from this domain. Perhaps call it your CDN.
When you reference a project to get at classes etc, the project is bundled up in to a dll and packaged along with the main project. Images, js files etc can't be bundled in to a dll, and will not be copied across to your project.
I have many projects that I want to build using TFS Build. I have no problems with Windows Forms and WebForms PROJECTS.
But when I try to use TFS Build to build ASP.NET Website (the classic one), I have these problems:
I don't have any options to compile the project with Test Configuration (only Debug or Release).
I can't build an ASP.NET website because it's not a Web Project.
I want to know if there's a way to publish the website's precompiled files to the same shared location where I have my other projects.
I think I might need a bit more detail here, or maybe I'm just clueless :-)
Test configuration - I'm assuming you've set up a Test build configuration? If so, I'm not sure off the top of my head what's going on, but I've seen people forget to create the build configuration.
We've had no problem with our Websites, they get moved to build output or to wherever you specify in the Website properties pages
If you mean you want to use WebDeploy to publish, you're out of luck for the website - only web projects will do that. But do a little team build customization, and you should be able to emulate that.
Not super satisfied with my answer, but hopefully I've pointed you towards something helpful...
I have a solution, Asp.Net web application and inside the solution I have two projects. One contains VB code that handles the UI. forms etc. and the other one C# that basically uses Linq-to-Entity to handle my data. When I run the project from my local computer it works good. Now, to publish, I notice only when the UI Project is selected, the publish option is enabled. Why is that? If I publish this, would the other project not be published? Another question, I have XML files created in app_data folder, when I publish it, will I be able to access it?
Publishing only applies to web projects. If you've included a reference to the other project in your web project, it will be compiled and the DLL will be published along with your web project. Your XML files should be published along with your web project, if they aren't check their properties and make sure they are set to be published with the project (build action set to Content and Copy Always or Copy if newer is selected).
You have two projects inside your solution. One is web project and the next will be a Class Library project. All the codes related to Entity framework, LINQ queries, Database transactions, etc should be in the class library project. while building the class library it will automatically generate the DLL files. then you need only add a reference to the web project file. Then you will get all the classes, methods etc from the class library. there is no need for publishing the class library project. Because you have add the dll reference to your webproject. all the code file inside your App_Code folder shuold be converted to dll while publishing the web project. so dont worry about the files inside the App_code folder data.
Thank you
You dont need to publish reference projects individually or even the whole solution. It works simply by referencing the dll of your other project.
Both projects need to be compiled if not already
If your UI project has reference to dll from data layer project it will be published with your UI project.
You can publish it locally in another folder and test using iis express or your local iis and then publish it online with database. Update connection string and it should work if setup correct.
I've recently started to explore Daniel Mohl "F# C# ASP.NET MVC3" template.
Can anyone share on how this type of project should be deployed to IIS7??
Thanks.
You deploy it pretty much the same way you'd deploy a "normal" ASP.NET MVC3 website, but there is one extra step: you need to make sure your deployed website will have access to FSharp.Core.dll.
If you have admin access to your server, you can simply install the F# redistributable; if not, you'll need to make sure FSharp.Core.dll is included when you publish or create a deployment package. The way I handled this in our website (written in MVC3 with C# + F#) was to manually add a reference to FSharp.Core to the website project, then right-clicked the reference, clicked properties, then set "Copy Local" to true. If you use any assemblies from the F# Powerpack, you'll need to do the same for them.
If I'm correct, the template consists of a C# Web Application that references F# Libraries (DLL) project which contains some of the functionality (namely, controllers and the model).
From the deployment point of view, this is just a normal C# Web Application with some referenced DLLs (created in F#) that will be copied to the bin directory, so the standard deployment procedure should for Web Applications should work just fine. I didn't try it myself now, but try:
Publish application to some folder (right click on C# web project in the solution explorer)
Copy that directory to your web server
Follow the usual IIS configuration steps (see for example here)
Every time I use Setup & Deployment to create a new Web Setup, and run it (after edit all the nice things in the properties), the output is always a copy of the Web Site project...
How can I output a PreCompile version of the WebSite project?
What I did was, publish the Web Site (so I get the precompiled version), add this new precompiled web site as an existing Web site to my solution and add it to the content output of the Setup...
well, the idea was good but I get an error saying:
"This application is already precompiled."
alt text http://www.balexandre.com/temp/stackoverflow_precompiledquestion.png
:-(
Bottom line is that I just want a Setup file that gives me the precompiled version of my Web project, how can I accomplish this?
I see you tried the standard Web Setup project from VS.
Scott Gu's blog post takes you to this page:
Visual Studio 2008 Web Deployment Projects
which is a plugin for Visual Studio that activates an additional "right click" option to any Web Site project to add such a deployment project. You can see here what I created.... And the output is a pre-compiled web application. Now, if you add a regular Web Setup project to your solution, and point it to the previously created Web Deploy project as its content, ... I got a valid build, no errors and an MSI file was created...with dlls inside it.
http://img222.imageshack.us/img222/6177/71881923mj9.jpg
I hope this helps you.
I was searching for this solution from google for long days. What i did is i precompiled my website to one folder and added that folder as a new website to my
solution(While adding it will give a warning message that it was already precompiled content. No probs). Now add this project output to the my setup project and one more important thing is in my web deployment project i just disabled Building of my precompiled
website.
I just got my thinks working. If you want you can try that.
Regards,
Rousseau.A
you may be having "PrecompiledApp.config" file in the root of your web application (please check in solution explorer).
I faced this issue and removed "PrecompiledApp.config" from solution explorer and solved the issue.