|
From my limited knowledge of MVC, I suspect you want to return a FileResult object by calling one of the File methods[^]:
public ActionResult StreakwaveReseller2015_DownloadApp()
{
return File("~/path/to/the/file.exe",
System.Net.Mime.MediaTypeNames.Application.Octet,
"TheDownloadFileName.exe");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My knowledge is limited as well here.
I thinks its a FileResult, I wrote this in the last 15 minutes, and it worked, very close to yours. Not sure if it's right or not.
But that's pretty slick in design, A action link on a view, in which the controller action lets you run the a small amount of code to download a file instead of showing another web page.
I have so much to learn here, I like being able to jam out code fast. Not bad considering I'm a VB guy by heart.
Let's see what others say about it. Thanks Richard!
public FileResult StreakwaveReseller2015_DownloadApp()
{
string filePath = Server.MapPath("~/Downloads/Streakwave/streakwave_1.1.0.784.exe");
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "streakwave_1.1.0.784.exe");
}
|
|
|
|
|
Just make sure your ~/Downloads/Streakwave/ folder is protected, so that nobody can download the file directly.
You can change the settings through IIS or appcmd [^], or add the following to the web.config file in that folder:
<configuration>
<system.webServer>
<handlers accessPolicy="None" />
</system.webServer>
</configuration>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The config turned off everything on me, server error 500.1 or something.
Should of used read, or something.
I just solved my redirect login, the IsLocalUrl, so I'll tackle that tomorrow morning.
You have to login or register to download the file.
[edit]
MVC does let you download the file in you type directly. Interesting. Maybe I should of put it in app_Data, since I'm reading the bytes.
|
|
|
|
|
The config file I posted should prevent you from downloading the file directly. I've used it on lots of sites without any problems.
If you're getting a 500 error when you add it, try accessing the site from the server to see the full details of the error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK, will give that a try today.
|
|
|
|
|
Hi Every Body,
Can any one help!
How to create a new MVC Application using any CMS Template.
Thanks in advance.
|
|
|
|
|
What do you mean by "using any CMS template"?
|
|
|
|
|
In asp.net which cms is provide more security for developing website? customized cms or third party cms like dnn,wordpress,umbraco,etc.. ?.
|
|
|
|
|
What do you mean by "more security"? More security features or what?
|
|
|
|
|
Sir,dnn,wordpress are open source so any one can hack immediately into the project.but customized cms is more secure than third party cms??
|
|
|
|
|
RajeeshMenoth wrote: so any one can hack immediately into the project
Since when does "open source" mean "less secure"? Having access to the source code does not mean you're going to know where all the weaknesses are. There are plenty of other things you have to do to the server that have nothing to do with the application code to properly secure the server.
|
|
|
|
|
I want to add navigation method in my project,but i am not able to add all navigation method Please give me coding of all method.
|
|
|
|
|
Yeah, that's not going to happen. There are simply too many different ways of doing navigation. All you have to go is Google for "ASP.NET navigation" and you'll come up with all kinds of ideas and 3rd party controls to do this.
|
|
|
|
|
Hi... run time i'm getting error as "Uh-oh, something went wrong! Error Code: 500".
In web.config file, i specified custom error mode to "off": <customerrors mode="Off">
Then also i'm getting same error..
any help appreciated...!
Thank you
|
|
|
|
|
That is a custom error, designed by the developer (maybe you) to hide the actual error in the background.
The 500 tells the developer that there has have been some run-time error, such as some error that broke the code and threw this error. Try re-loading the website in your IIS to re-compile and start the website's settings from beginning. Then it would display the error.
(If you're using Visual Studio as your IDE)
Otherwise, a side-note can be to debug the website using Visual Studio. Add a breakpoint to your functions, and Visual Studio would help you in catching the errors.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Special credit for code below goes to the great Richard Deeming.
Originally, the code was intended to search by date range or specific date.
Currently, a couple of changes have been made to the code per user specs.
Search is now done specifically with date range using jQuery datepicker.
The range could be just one day or multiple days.
Requirement 1: User selects a begin date, let's say 02/22/2015 and end date 02/22/2015(1 day).
The user selection searches Reservations table to see if the date(s) user selected have already been used for prior reservations.
If the date(s) have been taken, present user with on month's worth of results including the taken dates.
If the date(s) have been taken, present one month's worth of results including the taken dates.
How do I modify code below to get it to work?
So far, I run the code and no results are displayed.
Thanks a lot in advance.
Private Sub showGrid()
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("conString").ConnectionString)
Dim cmd As New SqlCommand("-placeholder-", conn)
Dim sb As New StringBuilder("Select siteID,siteName,AssetName,Capacity,AvailableFacilities,dateReserved,GroupStatus " & _
",amenities,RentalFeeAmount,ExtraHourAmount,DepositAmount,CancellationAmount,KeyDepositAmount, Duration " & _
" FROM ParksNRecsData WHERE siteId = @siteCode and capacity <= @roomcapacity and (CONVERT(VARCHAR(10), dateReserved, 101) >= @FromDate And CONVERT(VARCHAR(10), dateReserved, 101) <= @EndDate)")
cmd.Parameters.AddWithValue("@siteCode", ddlParks.SelectedValue)
cmd.Parameters.AddWithValue("@roomcapacity", ddlPartySize.SelectedValue)
cmd.Parameters.AddWithValue("@FromDate", txtFromDate.Text)
cmd.Parameters.AddWithValue("@EndDate", txtToDate.Text)
cmd.CommandText = sb.ToString()
Dim dt As DataTable = GetData(cmd)
If dt.Rows.Count = 0 Then
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@FromDate", Date.Today.ToString("MM/dd/yyyy"))
cmd.Parameters.AddWithValue("@EndDate", Date.Today.AddMonths(1))
cmd.CommandText = "Select siteID,siteName,AssetName,Capacity,AvailableFacilities,dateReserved,GroupStatus " & _
",amenities,RentalFeeAmount,ExtraHourAmount,DepositAmount,CancellationAmount,KeyDepositAmount, Duration " & _
" FROM ParksNRecsData" & _
" where dateReserved Between @FromDate And @EndDate"
dt = GetData(cmd)
End If
gvCustomers.DataSource = dt
gvCustomers.DataBind()
End Sub
|
|
|
|
|
I need to convert html div content to ms word in below code C# Microsoft.office.interop.word.htmldivision add invalid parameter error occurred.
StringBuilder objStrBuilder = new StringBuilder();
objStrBuilder.Append("<table>");
objStrBuilder.Append("<tr>");
objStrBuilder.Append("<td>");
objStrBuilder.Append("HP");
objStrBuilder.Append("<\td>");
objStrBuilder.Append("<td>");
objStrBuilder.Append("HP computer");
objStrBuilder.Append("<\td");
objStrBuilder.Append("<\tr>");
objStrBuilder.Append("<tr>");
objStrBuilder.Append("<td>");
objStrBuilder.Append("HP Labs");
objStrBuilder.Append("<\td>");
objStrBuilder.Append("<td>");
objStrBuilder.Append("HP computer Joy");
objStrBuilder.Append("<\td");
objStrBuilder.Append("<\tr>");
objStrBuilder.Append("<\table>");
dic.InnerHtml = objStrBuilder.ToString();
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
word = null;
try
{
object missing = System.Reflection.Missing.Value;
word = new Microsoft.Office.Interop.Word.Application();
object template = @"D:\\DS_Template11.dotx";
word.Documents.Add(Template: ref template);
word.Visible = true;
object readOnly = false;
object filename = "http://localhost:60510/tr/Default.aspx";
Microsoft.Office.Interop.Word.Document document = word.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
// Microsoft.Office.Interop.Word.Section wordSectio = document.Sections;
foreach (Microsoft.Office.Interop.Word.Section wordSectin in document.Sections)
{
foreach (Microsoft.Office.Interop.Word.HTMLDivision wordSection in document.HTMLDivisions)
{
String text = "this is footer";
//Get the footer range and add the footer details.
Microsoft.Office.Interop.Word.Section s1=document.Sections.Add(); ;
Microsoft.Office.Interop.Word.Paragraph p1 = document.Paragraphs.Add();
Microsoft.Office.Interop.Word.Range R1 = p1.Range;
Microsoft.Office.Interop.Word.HTMLDivision h1= R1.HTMLDivisions.Add();
h1.
R1.ContentControls=dic.
R1.HTMLDivisions = dic.InnerHtml;
//Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
Microsoft.Office.Interop.Word.HTMLDivision para = wordSection.HTMLDivisions.Add(dic.InnerHtml);
Range.Fields.Add(Range, Microsoft.Office.Interop.Word.WdFieldType.wdFieldHTMLActiveX);
modified 13-Feb-15 6:16am.
|
|
|
|
|
Is this a question, a proud boast, or just some spam?
|
|
|
|
|
Dude this is query sure if know the answer then reply plz
|
|
|
|
|
You still have not asked a question. Please edit your original post and add some proper detail about what problem you are trying to solve, and what errors or problems you are facing.
|
|
|
|
|
I need to convert an HTML Div which is made dynamically and run the page ,entire content of page should be converted into word document on client machine only
|
|
|
|
|
Did you understand what I mean by the statement: Please edit your original post and add some proper detail about what problem you are trying to solve, and what errors or problems you are facing.? Telling us what you want, is not an explanation of a problem.
Also looking at your code you are running some C# code using Microsoft.Office.Interop.Word . Is this running at the server or the client? If the latter then I do not think it will work.
|
|
|
|
|
how do I insert a word, pdf and text to sql database and view the files in gridview using vb.asp
|
|
|
|
|
The same way you would with another technology. Be sure to use a parameterized statement.
|
|
|
|
|